To zapytanie zawiera wyrobów name
, image
, price
, quantity
, description
SET @etype = (SELECT
entity_type_id
FROM
eav_entity_type
WHERE
entity_type_code = 'catalog_product');
wyrobów name
atrybut ID
SET @name = (SELECT
attribute_id
FROM
eav_attribute
WHERE
attribute_code = 'name'
AND entity_type_id = @etype);
wyrobów image
atrybut ID
SET @image = (SELECT
attribute_id
FROM
eav_attribute
WHERE
attribute_code = 'image'
AND entity_type_id = @etype);
wyrobów mały atrybut obrazu ID
SET @smallimage = (SELECT
attribute_id
FROM
eav_attribute
WHERE
attribute_code = 'small_image'
AND entity_type_id = @etype);
wyrobów price
atrybut id
SET @price = (SELECT
attribute_id
FROM
eav_attribute
WHERE
attribute_code = 'price'
AND entity_type_id = @etype);
ID produktu description
atrybut
SET @description = (SELECT
attribute_id
FROM
eav_attribute
WHERE
attribute_code = 'description'
AND entity_type_id = @etype);
- Admin sklep ID - SET @store = 0;
SELECT
e.entity_id AS 'id',
e.sku,
v1.value AS 'name',
v2.value AS 'image',
s2.value AS 'small_image',
si.qty AS 'stock qty',
d1.value AS 'price',
s1.value AS 'description'
FROM
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
catalog_product_entity_varchar s2 ON e.`entity_id` = s2.entity_id
AND s2.store_id IN (0,1,2)
AND s2.`attribute_id` = @smallimage
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 ;
Należy rozważyć zapewnienie prawidłowego DDL (i/lub sqlfiddle) RAZEM Z ŻĄDANYM ZESPOŁEM WYNIKÓW. – Strawberry
Dzięki. Ale czy możesz tutaj napisać pełny kod?Która tabela zawiera nazwę produktu? – user3580780
@ user3580780. Nie sądzę, że sposób w jaki to robisz jest niezawodny. Istnieje wiele atrybutów w tabeli 'eav_attribute' z tym samym kodem dla różnych encji (" opis "i" nazwa "są dla kategorii i produktów). Jeśli zrobisz to w ten sposób, możesz uzyskać zły warunek łączenia, a nie uzyskasz żadnych wyników. – Marius