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
    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
    May 15, 2018 at 18:27
  • 1
    Yes, this is perfect code, you will get custom attribute value after this code.
    – kunj
    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
    May 16, 2018 at 11:32

Your Answer

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

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