I have created some custom product types that extend from simple products. These product types will all have the same custom options added, so I'd like to just set those options on the product when saved as well as removing any other options that might have been added accidentally.

In my product type model, I have added the following save() method:

//My_Module_Model_Product_Type_Customtype extends Mage_Catalog_Model_Product_Type_Simple

public function save($product = null)
    $option = array(
        'title' => 'My Options',
        'type' => 'field',
        'is_require' => 0,
        'price' => 5,
        'price_type' => 'fixed',
        'sku' => 'mysku'

    $optionInstance = $product->getOptionInstance();

    return $this;

When I load an existing product of my type that does not have custom options assigned, the option I am adding inside save() can not be seen after the product saves; however, if I add a custom option from the admin form and then save, my option added in save() does get added. It seems the option will only get saved if the product already has a custom option assigned through the admin

I am guessing I am missing something basic, but can't seem to find what it is.


I took a look at the catalog_product_option table, and the option I add in save() is listed here, but it doesn't appear on the product's custom options tab unless I add an additional option manually from admin.


It seems that $product->setHasOptions() isn't working. When I look at catalog_product_entity, that value is 0. Manually changing it to 1 resolves the issue.

How am I supposed to save custom product type data while in the save() method?

  • This is a common problem. A way around is to wrap your rourine in a registry flag. So action if flag is not set. Set flag when actioned. This will block the recursion.
    – ProxiBlue
    Sep 18, 2016 at 0:19

1 Answer 1


I was working on something similar today - I would try to get all current options, push your new option(s) onto that array and do this:


The first line is explained here (not sure if you'd need it actually): https://stackoverflow.com/questions/4006260/magento-accumulating-custom-options-in-script

Edit: By the way, this code is working perfectly for me, however I'm using it in a script in development

  • $product->save() calls itself as I am currently working inside save(). This would just cause recursion.
    – pspahn
    May 28, 2015 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.