I am porting a Magento 1 module, which adds a custom category attribute, to Magento 2.

The product is already created in Magento 2 - but now it does not appear in the inside \Magento\Catalog\Helper\Category::getCategoryUrl.

In the Magento 1 version config.xml I had:

                      <redirect_url />

This solved the problem.

What is the equivalent of this in Magento 2 ?

Sure, I could load the full category item again in the above method, but this would slow down the site.


Create etc/catalog_attributes.xml in your extension with 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_category">
        <attribute name="redirect_url"/>
|improve this answer|||||
  • Does not seem to work for Magento2.1 anymore?! – Alex Jul 2 '16 at 21:30
  • I can confirm that this does work on 2.1 - just make sure that "Used in Product Listing" is set to Yes. – bassplayer7 Jan 5 '17 at 15:24
  • @bassplayer7 Use in product listing for a category attribute? - how does that work? – Alex Jul 11 '17 at 20:12

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.