如何仅使用MySQL来获取Magento中的所有product id, skus, product names, description, images, category
?
答案 0 :(得分:0)
SELECT p.`entity_id`, p.`sku`, pv.`value` as name, pt.`value` as description, GROUP_CONCAT(DISTINCT(cp.`category_id`) SEPARATOR ', ') as categories, GROUP_CONCAT(DISTINCT(pm.`value`) SEPARATOR ', ') as imagesPath
FROM `catalog_product_entity` as p
INNER JOIN `catalog_product_entity_varchar` as pv on pv.`entity_id` = p.`entity_id` and pv.`attribute_id` = 71
INNER JOIN `catalog_product_entity_text` as pt on pt.`entity_id` = p.`entity_id` and pt.`attribute_id` = 72
INNER JOIN `catalog_category_product` as cp on cp.`product_id` = p.`entity_id`
LEFT JOIN `catalog_product_entity_media_gallery` as pm on pm.`entity_id` = p.`entity_id` and pm.`attribute_id` = 88
GROUP BY cp.`product_id`, pm.`entity_id`
该查询是为EE v1.13.1.0设计的,它应该适用于其他版本,但在eav_attribute
表中重新检查您的attributeIds
答案 1 :(得分:0)
此查询根据admin storeID&amp ;;返回产品名称,sku,价格,图片,说明。另外两个也是..
SET @etype =(SELECT entity_type_id 从 eav_entity_type 哪里 entity_type_code ='catalog_product'); - 产品名称属性ID SET @name =(SELECT attribute_id 从 eav_attribute 哪里 attribute_code ='name' AND entity_type_id = @etype); - 产品图像属性ID SET @image =(选择 attribute_id 从 eav_attribute 哪里 attribute_code ='image' AND entity_type_id = @etype);
- 产品价格属性ID
SET @price =(SELECT attribute_id 从 eav_attribute 哪里 attribute_code ='price' AND entity_type_id = @etype);
- 产品描述属性ID
SET @description =(SELECT attribute_id 从 eav_attribute 哪里 attribute_code ='description' AND entity_type_id = @etype);
- 查询
选择
e.entity_id AS'id',
e.sku,
v1.value AS'name',
v2.value AS'image',
si.qty AS'stock qty',
d1.value AS'价格',
s1.value AS'描述'
从
catalog_product_entity e
LEFT JOIN
cataloginventory_stock_item si ON e.entity_id = si.product_id
LEFT JOIN
catalog_product_entity_varchar v1 ON e.entity_id = v1.entity_id
AND v1.store_id IN(0,1,2)
AND v1.attribute_id = @name
LEFT JOIN
catalog_product_entity_varchar v2 ON e.entity_id = v2.entity_id
AND v2.store_id IN(0,1,2)
AND v2.attribute_id = @image
LEFT JOIN
LEFT JOIN
catalog_product_entity_decimal d1 ON e.entity_id = d1.entity_id
AND d1.store_id IN(0,1,2)
AND d1.attribute_id = @price
LEFT JOIN
catalog_product_entity_text s1 ON e.entity_id = s1.entity_id
AND s1.store_id IN(0,1,2)
AND s1.attribute_id = @description;