I need to find a way to access attributes in a cart, I am able to do it in a product view with this code

public function getProductInfo() {
        $product = $this->getCurrentProduct();
        $attributes = $product->getAttributes();

        $productSet = array(
            'id' => $product->getId(),
            'sku' => $product->getSku(),
            'name' => $product->getName(),
            'price' => $product->getPrice(),

        foreach ($attributes as $attribute) {
            if ($attribute->getIsVisibleOnFront()) {
                $attributeCode = $attribute->getAttributeCode();
                $label = $attribute->getFrontend()->getLabel($product);      
                $value = $attribute->getFrontend()->getValue($product);
                $productSet[$label] = $value;
        return $productSet;

It works perfect and pulls all attributes, however when I try to do it in cart with this code

public function getCartInfo() {
        $cart = Mage::getModel('checkout/cart');
        $quote = $cart->getQuote();
        $counter = 1;
        $outArray = array();

        if ($quote && $quote->getId()) {
            $outArray = array(
                'items_count' => $cart->getItemsCount(),
                'items_qty' => $cart->getItemsQty(),
                'customer_id' => ($quote->getCustomerId()) ? $quote->getCustomerId() : 0,
                'grand_total' => $quote->getGrandTotal(),
                'base_grand_total' => $quote->getBaseGrandTotal(),
                'subtotal' => $quote->getSubtotal(),
                'base_subtotal' => $quote->getBaseSubtotal(),
                'store_id' => $quote->getStoreId(),
                'currency_code' => Mage::app()->getStore()->getCurrentCurrencyCode(),

            foreach ($cart->getItems() as $product) {
                $productId = $product->getProduct()->getId();
                $productPrice = $product->getProduct()->getPrice();
                $attributes = $product->getProduct()->getAttributes();
                $outArray['qty' . $counter] = $product->getQty();
                $outArray['id' . $counter] = $productId;
                $outArray['Price' . $counter] = $productPrice;
                foreach ($attributes as $attribute) {
                    if ($attribute->getIsVisibleOnFront()) {
                        $attributeCode = $attribute->getAttributeCode();
                        $label = $attribute->getFrontend()->getLabel($product);      
                        $value = Mage::getModel('catalog/product')->load($productId)->getAttributeText($attributeCode);
                        $outArray[$label . $counter] = $value;
        return $outArray;


it only pulls in some, the weird part is if I use

$value = $attribute->getFrontend()->getValue($product->getProduct());

it pulls in 3-4 attributes, and all others are No, then if I use

$value = Mage::getModel('catalog/product')->load($productId)->getAttributeText($attributeCode);

it pulls in 3-4 other attributes, but ones previously available through getValue are now false

So I need to somehow figure out how to pull in all attributes visible in frontend

Any ideas?


  • $value = Mage::getModel('catalog/product')->load($productId); Print_r($value->getData()); – Keyul Shah Sep 28 '14 at 7:50

Try to add the missing attributes in your models config.xml

|improve this answer|||||
  • Hi @schasiepen, thank you for above. But just a newb question, since I've not worked with config.xml before, where do I find it? I have one in the extension folder, and one in the app/etc/config.xml. in the app/etc config I see global -> models should I put it into there? so far all I have in there is varien, core & core_resources – user14186 Sep 30 '14 at 11:46

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.