cancel
Showing results for 
Search instead for 
Did you mean: 

How to add new products through magento database?

How to add new products through magento database?

I am trying to bring products from mysql database to magento database. Could you please help which tables i have to insert the data? as i am using sql triggers.

1 REPLY 1

Re: How to add new products through magento database?

Hi @vajeevan 

 

Please use following queries to create new product and set product's respective values:

 

1. insert new product
INSERT INTO `catalog_product_entity` (`entity_id`, `attribute_set_id`, `type_id`, `sku`, `has_options`, `required_options`, `created_at`, `updated_at`) VALUES (NULL, '4', 'simple', 'my-sku-test', '0', '0', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
[get entity id of new product]

2. Set status of new product using entity_id
INSERT INTO `catalog_product_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (NULL, '97', '1', '17', '1');

3. Set visibility of product using entity_id
INSERT INTO `catalog_product_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (NULL, '99', '0', '17', '4')

4. Set tax_class_id of product
INSERT INTO `catalog_product_entity_int` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (NULL, '134', '0', '17', '0')

5. Set filter_price_range of product
INSERT INTO `catalog_product_entity_decimal` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (NULL, '77', '0', '17', '100');

6. Set weight of product
INSERT INTO `catalog_product_entity_decimal` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (NULL, '82', '0', '17', '10')

7. Set quantity of product
INSERT INTO `cataloginventory_stock_item` (`item_id`, `product_id`, `stock_id`, `qty`, `min_qty`, `use_config_min_qty`, `is_qty_decimal`, `backorders`, `use_config_backorders`, `min_sale_qty`, `use_config_min_sale_qty`, `max_sale_qty`, `use_config_max_sale_qty`, `is_in_stock`, `low_stock_date`, `notify_stock_qty`, `use_config_notify_stock_qty`, `manage_stock`, `use_config_manage_stock`, `stock_status_changed_auto`, `use_config_qty_increments`, `qty_increments`, `use_config_enable_qty_inc`, `enable_qty_increments`, `is_decimal_divided`, `website_id`) VALUES (NULL, '17', '1', '1000', '0.0000', '1', '0', '0', '1', '1.0000', '1', '0.0000', '1', '0', NULL, NULL, '1', '0', '1', '0', '1', '0.0000', '1', '0', '0', '0');

8. Set name of product
INSERT INTO `catalog_product_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (NULL, '73', '0', '17', 'my-sku-test');

9. Set url of product
INSERT INTO `catalog_product_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES (NULL, '121', '0', '17', 'my-sku-test');

NOTE: Please set attribute_id and entity_id according to your database.

product_by_query.png

 

 

Issue solved ?
Please click on Kudos & accept as Solution !

Problem solved? Click Accept as Solution!