1

I have created a custom attribute so we can mark products as either "Best Seller", "Customer Favourite" or "Express Service".

I want to pull this information through to the category pages, so I can show a small icon in the top right of each product that has this customer attribute set.

In Magento 1 this was as simple as using the addAttributeToSelect method.

However, everything I can see for Magento 2 tells me I need to create a new module and extend existing core code just to achieve the same thing.

Is this correct? Is there no easier way of getting at custom attributes?


If it is correct can somebody explain the logic to me behind this decision making process. Why make a common customizable feature so complex to get at in comparason in the new version of Magento?

  • In magento 2 there is attribute.xml – DEEP JOSHI May 10 '16 at 8:40
  • ...keep going... – Jimmery May 10 '16 at 8:42
0

Yes it will require new module.

Try this code replacing your attributes:

Create catalog_attributes.xml in etc folder.

<?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_category">
        <attribute name="name"/>
        <attribute name="is_active"/>
    </group>
</config>

This code will take attribute from Cart -> Quote -> Order -> Invoice -> Shipment -> Credit memo

|improve this answer|||||

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.