1

I am having trouble comparing the items already in my cart with the item that was just added to the cart. Since I have attributes that are added via module instead of in each product, the item is just using whatever configuration the previous one had.

I am using the Mage_Sales_Model_Quote_Item to check this, and if I just return: false every time, it does add each item separately, so I know this is being called. Now instead of just adding each one separately even if they're the same, I want to check and add it as a quantity increase instead of a separate item.

Here's the class:

class ECB_ModifyMeal_Model_Sales_Quote_Item
    extends Mage_Sales_Model_Quote_Item
{
    public function representProduct($product) {
        $bool = false;
        $productExP = $product->getData('exclude_protein');
        $productSubP = $product->getData('sub_protein');
        $productExS = $product->getData('exclude_sides');
        $productSubS = $product->getData('sub_sides');

        $itemProduct = $this->getQuote()->getAllVisibleItems();
        foreach($itemProduct as $item){
            $itemExP = $item->getData('exclude_protein');
            $itemSubP = $item->getData('sub_protein');
            $itemExS = $item->getData('exclude_sides');
            $itemSubS = $item->getData('sub_sides');

            if($productSubS == $itemSubS){
                $bool = true; //same product
                break;
            }
        }
        return $bool;
    }
}

I've tried a few different variations of 'getAllVisibleItems' and none of them worked. Is there another way to get these attributes? I know that these are the same names I have used when setting them up.

0

Your Answer

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