Magento add product size and attribute inventory

Magento add product size and attribute inventory

October 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento add product size and attribute inventory

Managing Inventory by Size in Magento: A Comprehensive Guide

Hello developers! Today, we’re diving into a common challenge faced by e-commerce businesses - managing inventory levels for products that come in multiple sizes or variants. Let’s take the example of selling shoes and discuss how to attribute inventory at the size level using Magento.

Understanding the Challenge

When you have products like clothes or shoes with different sizing options, tracking inventory becomes complex. You need to know exactly how many items are available for each specific size variant. This requires more than just a standard product with quantity - it necessitates managing attributes and inventory at a granular level.

For instance, if you’re selling shoes in sizes 41 to 45 with varying quantities like 5 pairs of each except size 45 which has only 2 pairs:

  • Size 41: 5 pairs
  • Size 42: 5 pairs
  • Size 43: 5 pairs
  • Size 44: 5 pairs
  • Size 45: 2 pairs

Using Magento’s Built-In Features

Magento 2 is designed to handle such scenarios with its attribute and inventory management features. Here are the steps:

  1. Create a size attribute: Navigate to Stores > Attributes > Product and add a new attribute for ‘Size’. Set it as a dropdown with options from 41 to 45.

  2. Set up configuration: Under Stores > Configuration > Inventory > Inventory, ensure that you have enabled the option to track inventory by SKU and by product attributes.

  3. Assign sizes to products: When creating or editing your shoe products, add the size attribute values in the ‘Variants’ section.

  4. Manage stock for each variant: In the same ‘Variants’ section, enter the available quantity for each specific size under the ‘Stock Quantity’ column.

Handling Multiple Products Efficiently

If you have many products and need to update them all at once, you don’t necessarily have to go through the front-end interface one by one. You can use Magento’s API or directly interact with the database.

For example, if you want to update inventory levels for all shoes in a specific category using SQL:

UPDATE catalog_product_entity_int AS pei
INNER JOIN eav_attribute AS ea ON (pei.attribute_id = ea.attribute_id)
SET pei.value = 'Your New Quantity'
WHERE pei.entity_type_id = 4 AND ea.attribute_code = 'size' AND pei.value IN ('41', '42', '43', '44');

This query updates the inventory levels for all products where entity_type_id is 4 (which corresponds to catalog_product_entity) and the attribute code is ‘size’. Replace 'Your New Quantity' with your desired stock value.

Best Practices

Conclusion

Managing inventory by size in Magento requires setting up the right attributes and utilizing the platform’s built-in features effectively. By following this guide, you can efficiently track your stock levels for each variant, ensuring better visibility and improved customer experience.

Remember, while direct database queries offer flexibility, always ensure you have a backup before running them to prevent data loss. Magento’s own interface provides a safer environment for most routine updates.

That’s all for today! Let me know in the comments below if you found this guide helpful or if you have any other questions about Magento inventory management. Happy coding!

Magento 2 Catalog Configuration

Our network