ruhul0

grab data

Sep 6th, 2020
2,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.52 KB | None | 0 0
  1. SET @etype = (SELECT
  2.                     entity_type_id
  3.                 FROM
  4.                     eav_entity_type
  5.                 WHERE
  6.                     entity_type_code = 'catalog_product');
  7.  
  8. SET @name  = (SELECT
  9.             attribute_id
  10.         FROM
  11.             eav_attribute
  12.         WHERE
  13.             attribute_code = 'name'
  14.                 AND entity_type_id = @etype);
  15.  
  16. SET @image  = (SELECT
  17.             attribute_id
  18.         FROM
  19.             eav_attribute
  20.         WHERE
  21.             attribute_code = 'image'
  22.                 AND entity_type_id = @etype);
  23.  
  24. SET @price  = (SELECT
  25.             attribute_id
  26.         FROM
  27.             eav_attribute
  28.         WHERE
  29.             attribute_code = 'price'
  30.                 AND entity_type_id = @etype);
  31.  
  32. SET @store = 0;
  33.  
  34.  
  35. SELECT
  36.     e.entity_id AS 'id',
  37.     e.sku,
  38.     v1.value AS 'name',
  39.     v2.value AS 'image',
  40.     si.qty AS 'stock qty',
  41.     d1.value AS 'price'
  42. FROM
  43.     catalog_product_entity e
  44.         LEFT JOIN
  45.     cataloginventory_stock_item si ON e.entity_id = si.product_id
  46.         LEFT JOIN
  47.     catalog_product_entity_varchar v1 ON e.entity_id = v1.entity_id
  48.         AND v1.store_id = @store
  49.         AND v1.attribute_id = @name
  50.         LEFT JOIN
  51.     catalog_product_entity_varchar v2 ON e.entity_id = v2.entity_id
  52.         AND v2.store_id = @store
  53.         AND v2.attribute_id = @image
  54.         LEFT JOIN
  55.     catalog_product_entity_decimal d1 ON e.entity_id = d1.entity_id
  56.         AND d1.store_id = @store
  57.         AND d1.attribute_id = @price;
Advertisement
Add Comment
Please, Sign In to add comment