How to Get Attribute Id by attribute code Magento 2?

Fetch Attribute Id from the attribute code in Magento 2 by using AttributeRepository Interface Class.

You need the Entity type value and the attribute code.

Just instantiate the Magento\Eav\Api\AttributeRepositoryInterface class to retrieve the id value. Continue reading “How to Get Attribute Id by attribute code Magento 2?”

How to update product attribute using Patch Data Magento 2?

Update Product attribute with Patch Data file in Magento 2.3 and above version.

Sometimes we have created a product attribute and want to change some of the fields after generating product attributes, you can do it easily with Magento.

Let’s take an example, We want to change product attributes of Open source sample data, Sale attribute title with Discount. Need to create a Setup folder in your module with the Patch\Data folder inside it and create any PHP file to update title. Continue reading “How to update product attribute using Patch Data Magento 2?”

Get Qty Increments value by product SKU Magento 2.

Get Product Qty Increments value programmatically by product id or SKU in Magento.

Qty Increments Value will be set from the Admin Panel and used to add qty in multiply of that value. If you have set value equals 5, You must have to add multiple of 5 in qty field to add a product. (Allowed Value 5, 10, 15, 20, etc…)

Go To Catalog -> Products -> Add/Edit Product,
Click on Advanced Inventory,
Select Options as Yes from the Enable Qty Increments dropdown and a new input field will be visible.
Now, Set Qty Increments Value as per your choice.
Save Product. Continue reading “Get Qty Increments value by product SKU Magento 2.”