Skip to content

Instantly share code, notes, and snippets.

@0-Sony
Last active September 12, 2022 12:43
Show Gist options
  • Save 0-Sony/cb0da0dc1f921afca9268fc64bf5314a to your computer and use it in GitHub Desktop.
Save 0-Sony/cb0da0dc1f921afca9268fc64bf5314a to your computer and use it in GitHub Desktop.
Magento2: Add stock for all products / Add price for all products
#Let's find the attribute_id of price
SELECT attribute_id, backend_type
FROM `eav_attribute`
WHERE attribute_code = 'price' AND entity_type_id = 4;
# For instance the attribute_id returned is 77
# /!\ Warning /!\
# Community Edition : use `entity_id`
# Enterprise Edition : use `row_id`
INSERT INTO catalog_product_entity_decimal (`attribute_id`, `store_id`, `value`, `entity_id`)
SELECT 77, 0, 99, `entity_id`
FROM `catalog_product_entity`
WHERE `entity_id` NOT IN (SELECT `entity_id` FROM catalog_product_entity_decimal WHERE `attribute_id` = 77)
UPDATE cataloginventory_stock_item SET qty = 100, is_in_stock = 1;
REPLACE INTO inventory_source_item (source_code, sku, quantity, STATUS)
SELECT 'my_stock_source', sku, 100, 1 FROM catalog_product_entity;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment