0

I have been working on showing custom options of simple product for grouped product. I am done with initial phase of allowing required custom option product and then showing it on frontend. I have modified checkout/cart/add to add products with custom option to cart. This is also working fine. But I see products are being added twice to cart. Once with custom option and another one without custom option. I have debugged app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php . Here, protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode) is responsible for adding product to cart. I tried adding custom option values of products from here. But couldn't succeed.

Note:- Here I am not trying to create new custom options. I just want to set the values of custom option.

Any help will be appreciated. Thanks in advance.

  • Please share your controller code and how you call it – PЯINCƏ Jul 11 '18 at 23:11
  • It will be difficult to share my code. But can you explain which code is responsible for adding grouped product to cart in Magento 1?? – Vivek Shahi Jul 12 '18 at 15:05
1

I have done it.

$cart->addProduct($product, $params);

This code was adding the products again. As I was adding them with custom option. I forgot to put this in condition. And both were working simultaneously.

0

if i am not mistaken, i think you want to add custom options when product added to cart.

to add your custom option you need to do this: call a event : catalog_product_load_after

<catalog_product_load_after>
    <observers>
        <some_name>
            <type>singleton</type>
            <class>namespace/modelname</class>
            <method>methodname</method>
        </some_name>
    </observers>
</catalog_product_load_after>

then in namespace/modelname/methodname

add this code:

$additionalOptions = array();
$additionalOptions[ ] = array(
    'label' => 'Print Method',
    'value' => $print_type,
);

$observer->getProduct()->addCustomOption('additional_options', serialize($additionalOptions));

and if you want to update the values just call same function with different additional array values.

hope this clear your doubt. feel free to ask questions,

thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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