Question

So I have a module, which I am using to set a custom field in bundle options. I have implimented my module successfully. However I came to a situation to which I can't move on without get an answer for this problem.

In my module, in order to save data to my custom fields, I am observing to <catalog_product_save_after />. In my custom table,along with my custom field id and its content, I want to save option_id and store_id. Things work fine, for product that have already bundle options. For such products, I can get option_id and store_id. But for newly created options for product, option_id field seems to empty. I don't know how to get option_id.

Method I am using to get option details : $product->getBundleOpitonsData()

When echo this, I am getting a result like this.

Array
(
[7] => Array
    (
        [description_id] => 
        [description_new] => 
        [title] => bla bla title
        [description] => bla bla description
        [option_id] => 
        [delete] => 
        [type] => select
        [required] => 1
        [position] => 
    )
 [1] => Array
    (
        [description_id] => 1
        [description_new] => no
        [title] => test
        [description] => new description
        [option_id] => 30
        [delete] => 
        [type] => select
        [required] => 1
        [position] => 0
    )

 ---------- 
)

As you can see, for newly created option(array[7]), option_id field is empty. But for an already existing option (array[1]), option_id DOES exist.

Note : In Mage_Bundle module, there is an observer for the event <catalog_product_prepare_save />. In the mentioned obsever, we can see that options are SETing.

public function prepareProductSave($observer)
{
    $request = $observer->getEvent()->getRequest();
    $product = $observer->getEvent()->getProduct();

    if (($items = $request->getPost('bundle_options')) && !$product->getCompositeReadonly()) {
        $product->setBundleOptionsData($items);
    }
}

If that is correct, before invoking my observer, option is setting through the bundle observer. Then Why option_id field is empty for new option ?

Please help me friends. I can't move on without your help. Eagerly waiting for your reponses

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top