0

I have configurable products in the shopping cart but i want to add one column with stock item the products by sizes

i have an observer

 <controller_action_predispatch_checkout_cart_index>
     <observers>
        <shopping_cart>
           <type>singleton</type>
           <class>Myspace_Mymodule_Model_Observer</class>
           <method>addExtraItemShoppingCart</method>
         </shopping_cart>
     </observers>
 </controller_action_predispatch_checkout_cart_index>





public function addExtraItemShoppingCart(Varien_Event_Observer $observer){
    $quote = Mage::getModel('checkout/session')->getQuote();
    $cartItems = $quote->getAllItems();

    foreach ($cartItems as $item){
        $productType = $item->getProduct()->getTypeId();
        if($productType!='configurable'){
            //Mage::log($item->getSku(), null, 'shoppingCartB2B.log',true);

            $product = Mage::getModel('catalog/product')->load($item->getProductId());
            $qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
            $size = $product->getResource()->getAttribute('talla')->getFrontend()->getValue($product);

            $item->setData('talla', $item->getId())->save();
        }
    }
    Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
}

and in the file app/design/frontend/THEME/default/template/checkout/cart/item/default.phtml

$_item->getData('talla');

print talla, but does not work.

if someone can help me, thank you.

0

i have solved the problem :) this is a solution. In the file

app/design/frontend/THEME/default/template/checkout/cart/item/default.phtml

add

$product_child = $_item->getProduct()->getTypeInstance(true)
->getOrderOptions($_item->getProduct());

$product_hild =  Mage::getModel('catalog/product')
            ->setStoreId(Mage::app()->getStore()->getId())
            ->loadByAttribute('sku',$product_child['simple_sku']);

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.