0

In my templates I want to have access to custom product attributes on the detail page, the cart and also the category list view. This can be (or should be) easily achieved by creating a Vendor/Module/etc/catalog_attributes.xml with for example the following content:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd">
    <group name="catalog_product">
        <attribute name="my_attribute"/>
    </group>
    <group name="quote_item">
        <attribute name="my_attribute"/>
    </group>
</config>

This works great in the cart or whenever I load a collection myself in custom controllers for example. The additional attributes are automatically loaded.

However for some reason it does not work in the product list of catalog_category_view. The attribute is not present in the loaded collection of the list/grid view.

Shouldn't the <group name="catalog_product"> also affect the category list view? Am I missing something?

1

I use the property 'Used in product listing' that you see in the pic below. May need your index running and cache cleared but mostly this should be straight forward. good luck.

enter image description here

  • Woah thank you, I was unaware of this attribute setting! – fritzmg Nov 17 '18 at 16:58

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.