Magento: add product twice to cart, with different attributes!

点点圈 提交于 2019-12-05 17:13:48
kushal mehta

Go to class Mage_Sales_Model_Quote and search for the method getItemByProduct($product) and make it return false; all the time. Be careful, this might interfere with the minimum & maximum allowed in cart for products.

i think your main problem is how you set up the products the attribute should be something like lens strength right eye, lens strength left eye, lens thickness right eye, lens thickness left eye. one attribute set can hold the different values you need

if you want to use separate attribute sets you could use bundled products ie all products come as a bundle and you need to add lenses to your purchase, lenses are a separate product with different attribute sets and pricing (which could be set to none)

maybe neither of these is a perfect fix but with some css and templating it should be able to look professional enough

You can create an observer

<catalog_product_load_after>
          <observers>
                  <subscription>
                      <type>singleton</type>
                     <class>Itdelight_Subscription_Model_Observer</class>
                     <method>catalogProductLoadAfter</method>
                 </subscription>
        </observers>
</catalog_product_load_after>

And then add your unique attribute in product.

public function catalogProductLoadAfter(Varien_Event_Observer $observer){
     $action = Mage::app()->getFrontController()->getAction();
    if ($action->getFullActionName() == 'checkout_cart_add')
    {
       if ($options = $action->getRequest()->getParam('spy'))
        {
            $product = $observer->getProduct();
            $product->addCustomOption('product_attribute','subscription');
            $a=$product->getCustomOption('product_attribute');


}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!