25

We can get custom attribute value like below Attribute Value <?php /* @escapeNotVerified */ echo $_product->getResource()->getAttribute('c_address')->getFrontend()->getValue($_product); ?> Label $address =$_product->getResource()->getAttribute('c_address')->getStoreLabel(); Note : in above line c_address is my custom ...


21

Official method should work, but Not The official method setCustomAttribute($attributeCode, $attributeValue) below should work but NOT because the official bug https://github.com/magento/magento2/issues/4703. The bug doesn't fix yet in version 2.2.3. $product = $this->productRepository->getById($productId); $product->setCustomAttribute($...


18

Yes, this is possible. First, set these keys in your $data array to following values to avoid adding attribute to all attribute sets: 'user_defined' => true, 'group' => '' Then add attribute to your attribute set: $attributeSetId = $this->getAttributeSetId($entityTypeId, 'New Attr Set'); $this->addAttributeToSet($...


18

When you create a attribute for a product EAV comes in a picture. To get a value you need to know basics, which magento uses to store eav data. For this following tables plays a important role. eav_attribute Whenever you create a attribute this table gets entry which stores all important data which helps to make a relation, like entity_type_id,...


16

To create product, we can use: POST: /V1/products For updating: PUT: /V1/products/{sku} In your case, your code should be: $productData = [ 'attribute_set_id' => 4, "type_id": "simple", "sku": "test-SKU", "name": "Test", "price": 100, "status": 1, 'custom_attributes' => [ ['...


16

In contrast to Magento 1, in Magento 2 you now need to add some XML to make custom attributes appear in the edit customer section of the admin. Create YourNamespace/YourModule/view/base/ui_component/customer_form.xml and add this (at a minimum): <?xml version="1.0" encoding="UTF-8"?> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...


14

Solution 1: You should delete attribute code dimension in eav_attribute table and recreate use 'input' => 'text' in array. After then, reindex + clear cache. [ 'type' => 'decimal', 'backend' => '', 'frontend' => '', 'label' => 'Dimension', 'input' => 'text', 'class' => '', 'source' => '', 'global' =>...


14

Here are the high-level things we need to do. Create Product custom attribute -> Which attribute you want to show the row pattern / dynamic rows Create di.xml -> Add our custom Data provider into the product form Create DataProvider -> Set row patter fields and data to the attribute Create Observer (events.xml) -> Add/Update attribute ...


12

I created an article about this, that have only 5 steps to do it: 1 - Create your attribute in Stores > Attributes > Product. 2 - Set the attribute in the Default group, go to Stores > Attributes > Attribute Set. 3 - Set the values of this attributes in your products. 4 - Open in your custom theme the relative file below: app/design/frontend/CUSTOM/...


11

This may help for you to save the custom attribute. protected $_customerRepositoryInterface; public function __construct( \Magento\Customer\Api\CustomerRepositoryInterface $customerRepositoryInterface, \Magento\Customer\Model\CustomerFactory $customerFactory ) { $this->_customerRepositoryInterface = $customerRepositoryInterface; $this-&...


11

Check below code is working great for me. Tested with Magento 2.3.3 $avatar = $this->request->getParam('avatar'); // \Magento\Customer\Model\Customer $customerModel, $customerNew = $this->customerModel->load($this->customerSession->getCustomer()->getId()); $customerData = $customerNew->...


10

Custom customer attributes will never just 'appear' on the frontend like they do in the backend. The code that displays them on the frontend is located in a custom phtml file. Magento EE has this functionality built in. I'm not suggesting you NEED to spend that money, I'm just saying it has it. If you want to go ahead and attempt to add custom ...


9

(Fortunately or not, but ) Join Processor (Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface) isn't used everywhere and in particular it is not used in Sales module. As result, extension attributes aren't automatically added to "getList" and "get" methods result for Orders, Invoices and other entities of Sales module. You should do that by ...


9

Yes , You can create specific attribute for specific product type programmatically. Below i have created Boolean type of attribute for configurable product only. You need to pass 'apply_to' parameter and its value as configurable try below code in your InstallData.php file : <?php namespace Vendor\ModuleName\Setup; use Magento\Eav\Setup\EavSetup; ...


9

Create File catalog_attributes.xml inside Vendor/Module/etc or any existing module. <?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="product-arrtibute"/> ...


8

Using the boolean source model instead of the table source model you can easily define the default 0: $installer->addAttribute('catalog_product', "best_seller_flag", array( 'type' => 'int', 'group' => 'Flags', 'input' => 'select', 'label' => 'Best seller flag', 'default' => '0', 'sort_order' =...


8

For saving data into order table try following way Vendor/Module/etc/events.xml <?xml version="1.0" encoding="UTF-8"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="sales_model_service_quote_submit_before"> <observer name="...


8

Resolved the issue by directly using the attribute_code within the search criteria. https://{domain}/rest/all/V1/products/?searchCriteria[filterGroups][0][filters][0][field]=isbn_13&searchCriteria[filterGroups][0][filters][0][value]=9780874810417 It finally returned the result.


7

It is pretty easy to do this in Magento 2.1. You need to add a row to the catalogrule table using the module (in your own module): app/code/Vendor/Rules/Setup/InstallSchema.php namespace Vendor\Rules\Setup; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\...


7

You can achieve this task by below 2 option Option - 1 You need to change 'created_at' column in view/adminhtml/ui-component/sales_order_grid.xml Change column <column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date"> to <column name="main_table.created_at" class="Magento\Ui\Component\Listing\Columns\Date"> Option -...


7

I've found out how to get list options I was looking for, it's possible to get attributes groups with array with options like so: http://magento2.dev/rest/V1/products/attributes?&searchCriteria[filterGroups][0][filters][0][field]=attribute_group_id&searchCriteria[filterGroups][0][filters][0][value]=31 Where 31 is the attribute_group_id of custom ...


6

config.xml Magento checks this XPath in the config.xml to get the attributes which are loaded automatically with a collection: /config/frontend/product/collection/attributes Example: app/code/core/Mage/Catalog/etc/config.xml:721 To add an attribute to the cart page, you need to load the attribute during the product loading of the quote_item_collection, ...


6

You have to just keep below code inside block file and call function inside your template, protected $productFactory; protected $dataObjectHelper; protected $productRepository; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Catalog\Api\Data\ProductInterfaceFactory $...


6

Use this $attribute = $_product->getResource()->getAttribute('identifier'); if ($attribute) { $attr_value = $attribute ->getFrontend()->getValue($_product); }


6

Magento 2.0.x version: First of all, there are some notes: --Replaced event catalog_product_prepare_save with controller product initialization helper that can be customized via plugins - Vendor/ProductRelation/Model/Product/Initialization/Helper/ProductLinks.php. --Replaced event catalog_model_product_duplicate with composite Product\Copier model. ...


6

1/ Magento Admin > Stores > Attributes / Product > Click on your custom attribute > Advanced Attribute Properties > Set "Add to Column Options" to "Yes" and click on "Save attribute" button 2/ Magento Admin > Products > Inventory / Catalog > Select your custom attribute on "Columns box"


6

Upload from the default CSV generated by Magento Yes, you need to fill all your custom attributes into the single-column named additional_attributes_code. Just simply put all your custom attributes in the following way into the column with the name additional_attributes_code into your imported CSV file. custom_attribute_code_1="Value_1",...


6

use \Magento\Catalog\Model\Product\Attribute\Repository; protected $productAttributeRepository; public function __construct( ... Repository $productAttributeRepository .... ) { .... $this->productAttributeRepository = $productAttributeRepository; .... } Now you can use this like to get product attribute $yourAttribute=$this->...


6

I used following code <?php namespace Custom\Module\Setup; use Magento\Framework\Setup\UpgradeDataInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Eav\Setup\EavSetup; class UpgradeData implements UpgradeDataInterface { public function __construct( EavSetup $...


6

For displaying product attribute in minicart 1. Create file catalog_attributes.xml Vendor/Module/etc <?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&...


Only top voted, non community-wiki answers of a minimum length are eligible