I have tried a lot of stuf but none of them work. I think I can get the custom attributes on the product page, but I was wondering: how to get them in shopping cart page? (the attribute is just a simple written text)
Magento 2 Marketplace Custom Attribute module allows the admin to create custom attribute from the admin panel and can select them to display/hide on the front end. Vendors can use those attributes during product upload and those attributes are displayed on the seller's product page.
$_item->getProduct()->load()
will reload all product data from the database. While this will work, bear in mind that every time you call load()
Magento will execute a database query.
The same can be done with much better performance by loading the attribute along with the quote item. Just create a custom module and add this to the config.xml
<global>
<sales>
<quote>
<item>
<product_attributes>
<one_custom_attribute_code />
<another_custom_attribute_code />
</product_attributes>
</item>
</quote>
</sales>
</global>
Having done that, you can access your custom attribute without additional database queries.
$_item->getProduct()->getAnotherCustomAttributeCode();
Here is an article about this: https://www.atwix.com/magento/accessing-custom-attribute-at-checkout-or-cart/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With