Thursday 13 December 2012

Shorter IDs without Site ID for Orders, Invoices and Shippments

I found it very strange that magento creates different ids for orders, invoices and shipments depending on the site_view.
Below sql statements create global ids, limit the code length to 5 plus a character prefix.
B = Orders, R = Invoices, V = Shipping
And I let all of them start with 13000.

You have to apply the script to a store without orders, invoices and shipments, otherwise you are in risk of having duplicate ids if you don't choose your prefix well.

I used to get rid of my test data.
UPDATE `magento`.`eav_entity_type` SET `increment_per_store` = '0' , `increment_pad_length` = '5' WHERE `entity_type_id` = '4'; 
UPDATE `magento`.`eav_entity_type` SET `increment_per_store` = '0' , `increment_pad_length` = '5' WHERE `entity_type_id` = '18'; 
UPDATE `magento`.`eav_entity_type` SET `increment_per_store` = '0' , `increment_pad_length` = '5' WHERE `entity_type_id` = '24'; 
UPDATE `magento`.`eav_entity_type` SET `increment_per_store` = '0' , `increment_pad_length` = '5' WHERE `entity_type_id` = '28'; 

TRUNCATE `eav_entity_store`;
ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1;

insert  into `eav_entity_store`(`entity_store_id`,`entity_type_id`,`store_id`,`increment_prefix`,`increment_last_id`) values (1,4,0,'B','B13000'),(2,18,0,'R','R13000'),(3,24,0,'V','V13000');

Tuesday 18 September 2012

Magento: Change Simple Product to Configurable Product

One of the big mysteries - at least to me - is why magento admin is not able to change a simple product to a configurable product.
It is obvious that this is a real world usecase!
Anyway: The guys from Flagbit GmbH delivered a free module to change the Attribute Set:

So far so good. But what is the use of a product with an different attribute set, when you still need it as configurable product.
I hacked the code. Now if you change the attribute set to 'default' then the product type is changed to 'simple'. Setting any other attribute set to the product leads to a product_type of 'configurable'.

Important: This code does not work with 'bundle' products.

What you need to do:

  • Find \app\code\community\Flagbit\ChangeAttributeSet\controllers\Adminhtml\Catalog\ProductController.php
  • Make a backup of this file
  • Find the public function changeattributesetAction()
  • Change it to:

public function changeattributesetAction()
  $productIds = $this->getRequest()->getParam('product');
  $storeId = (int)$this->getRequest()->getParam('store', 0);
    $attribute_set = $this->getRequest()->getParam('attribute_set');

    $entityTypeId = Mage::getModel('eav/entity')
    $attributeSetName = Mage::getModel('eav/entity_attribute_set')
                    ->addFieldToFilter('attribute_set_id', $attribute_set)
    if ($attributeSetName == 'Default') { $product_type = 'simple'; } else { $product_type = 'configurable'; }
  if (!is_array($productIds)) {
   $this->_getSession()->addError($this->__('Please select product(s)'));
  else {
   try {
    foreach ($productIds as $productId) {
     $product = Mage::getSingleton('catalog/product')
          $product = Mage::getSingleton('catalog/product')

    Mage::dispatchEvent('catalog_product_massupdate_after', array('products'=>$productIds));
     $this->__('Total of %d record(s) were successfully updated', count($productIds))
   catch (Exception $e) {
    $this->_getSession()->addException($e, $e->getMessage());
  $this->_redirect('adminhtml/catalog_product/index/', array());

  • That's all!

Feel free to add comments.

Credits: Thanks to for the syntax highlighter tutorial.

Wednesday 15 August 2012

Find older versions of PHP Extensions

If you search for an PHP extensions of an older PHP version and can't find it on then you want to give a chance.
I found my there.
Hope this helps someone. I searched for 2 hours for this archive. ;)

Tuesday 5 June 2012

Fixed: Spellcheck in Magento Admin

This is a quick solution to get spellcheck in magento working.
It worked for me with magento 1.6.2.
The best solution is the creation of an extension, but I didn't take the time.
Also beware that with the next magento update the changes will be overwritten.

 1) Add the red parts to \js\mage\adminhtml\wysiwyg\tiny_mce\setup.js
        theme_advanced_buttons1 : magentoPlugins + 'magentowidget,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect',
            theme_advanced_buttons2 : 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor',
            theme_advanced_buttons3 : 'tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,ltr,rtl,|,fullscreen,|,spellchecker',
            theme_advanced_buttons4 : 'insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,pagebreak',
            theme_advanced_toolbar_location : 'top',
            theme_advanced_toolbar_align : 'left',
            theme_advanced_statusbar_location : 'bottom',
            theme_advanced_resizing : true,
            convert_urls : false,
            relative_urls : false,
            content_css: this.config.content_css,
            custom_popup_css: this.config.popup_css,
            magentowidget_url: this.config.widget_window_url,
            magentoPluginsOptions: magentoPluginsOptions,
            spellchecker_languages : 'English=en,+Deutsch=de',
Add the spellchecker_languages (see lines above) according to you needs:
This enables you to specify what languages your pspell installation can handle. The value of this option should be a comma separated name value list in the following format name1=value1,name2=value,name3=value where name is the string to present in the menu and the value is a ISO language code like sv or en. If you add a + character infront of the name it will be the default value for the spellchecker. The default value for this option is: +English=en.

 2) Go to  and get the PHP Spellchecker.

3) Put the folder spellchecker from this zip inside \js\tiny_mce\plugins

That's all. Have fun.