2

I have the following in my custom module:

$product = $quote_item->getProduct();

If I then do this I see the product id:

var_dump($product->getId());

This though gives me null:

var_dump($product->getAttributeText('manufacturer'));

But this gives me the manaufacturer:

$product = Mage::getModel('catalog/product')->load($quote_item->getProductId());

var_dump($product->getAttributeText('manufacturer'));

I can't use the second option becuase I am adding to some existing code which I do not want to break. Taking the first example how can I access the AttributeText property and why in my case is it empty?

1
  • Have you already found a solution?
    – sv3n
    Commented Jul 2, 2018 at 16:20

1 Answer 1

1

If you want to add custom attributes to quote items, you have to declare them first.

Add this to your modules config.xmlglobal section:

    <sales>
        <quote>
            <item>
                <product_attributes>
                    <manufacturer />
                </product_attributes>
            </item>
        </quote>
    </sales>
3
  • So does this force the custom attribute to be included when i call getProduct on the quote item?
    – Alan A
    Commented May 15, 2018 at 18:27
  • 1
    Yes, this is perfect code, you will get custom attribute value after this code.
    – kunj
    Commented May 15, 2018 at 18:31
  • @AlanA Yes, this attribute should be included in getProduct() data. Please let me know if it works for you :)
    – sv3n
    Commented May 16, 2018 at 11:32

Your Answer

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

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