Hola. Estoy con la migración de Magento 1.9 a Magento 2.2.4 y no soy capaz de mostrar un atributo personalizado que tengo para cada producto en el carrito. En este caso es el Atributo Plazo de Entrega que tenemos para cada producto.
¿Me podrían ayudar?
Gracias.
Solved! Go to Solution.
There is new concept in Magento 2 to create catalog_attributes.xml file in which you can define your custom attribute value using quote_item group section.
You Just need to create app/code/Vendor/Modulename/etc/catalog_attributes.xml with below 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="quote_item">
<attribute name="custom_attribute_name"/>
</group>
</config>
You can get custom_attribute_name in the template file withcart/item/default.phtml
below code.
echo $_item->getProduct()->getData('custom_attribute_name');
Clear Cache and check.
There is new concept in Magento 2 to create catalog_attributes.xml file in which you can define your custom attribute value using quote_item group section.
You Just need to create app/code/Vendor/Modulename/etc/catalog_attributes.xml with below 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="quote_item">
<attribute name="custom_attribute_name"/>
</group>
</config>
You can get custom_attribute_name in the template file withcart/item/default.phtml
below code.
echo $_item->getProduct()->getData('custom_attribute_name');
Clear Cache and check.
Hola Damian.
Ya lo he resuelto