magento 1.9通过sql查询插入产品

时间:2018-09-17 16:55:30

标签: php mysql magento

我想直接使用sql插入产品,这些是我用相对查询填充的表,类别1是根目录,已经存在19:

INSERT INTO etpq_catalog_product_entity ( entity_type_id, attribute_set_id, type_id, sku, has_options, required_options, created_at, updated_at ) VALUES ( 4, 4, 'simple', 'SKUPRO', 0, 0, NOW(), NOW() );  

//category
INSERT INTO etpq_catalog_category_product ( category_id, product_id, position ) VALUES ( 1, 23425, 2 ), ( 19, 23425, 2 ); 

//quantity
INSERT INTO etpq_cataloginventory_stock_item ( product_id, stock_id, qty, is_in_stock, cfg_manage_stock, manage_stock, min_sale_qty, max_sale_qty ) VALUES ( 23425, 9, 1, 1, 1, 1, 1 ); 

INSERT INTO etpq_cataloginventoty_stock_status ( product_id, website_id, stock_id, qty, stock_status ) VALUES ( 23425, 1, 1, 9, 1 ); 

//name
INSERT INTO etpq_catalog_product_entity_varchar ( entity_type_id, attribute_id, store_id, entity_id, value ) VALUES( 4, 71, 4, 23425, :value );

//description
INSERT INTO etpq_catalog_product_entity_text ( entity_type_id, attribute_id, store_id, entity_id, value ) VALUES( 4, :attribute_id, 4, 23425,, :entity_id, :value );
//weight 
INSERT INTO etpq_catalog_product_entity_decimal ( entity_type_id, attribute_id, store_id, entity_id, value ) VALUES( :entity_type_id, :attribute_id, :store_id, :entity_id, :value );


//price
INSERT INTO etpq_catalog_product_entity_decimal ( entity_type_id, attribute_id, store_id, entity_id, value ) VALUES( :entity_type_id, :attribute_id, :store_id, :entity_id, :value );


//visibility
INSERT INTO etpq_catalog_product_entity_int ( entity_type_id, attribute_id, store_id, entity_id, value ) VALUES( 4, 102, 4, 23425, 4 );

INSERT INTO etpq_catalog_product_website ( website_id, store_id ) ) VALUES( :website_id, :store_id );

该产品未列入magento的管理产品中,是否缺少某些东西?

3 个答案:

答案 0 :(得分:1)

在这一点上,您只能在magento管理面板上查看该产品。 如果您在catalog_category_product_index上插入值,则可以通过UI看到产品。

答案 1 :(得分:0)

您可以从phpmyadmin下载当前数据库,并将产品信息添加到sql文件,然后上传。您需要执行许多查询才能上传产品。或者,如果您有大型数据库,则只能从phpmyadmin下载数据结构。我认为,这是在这种情况下上传产品的最短方法。

答案 2 :(得分:0)

有必要将产品属性插入store_id = 0(Admin)以及所需商店的store_id中,以使其显示在产品列表管理器中。