Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stock/Inventory SQL #8

Open
Genaker opened this issue Oct 12, 2021 · 0 comments
Open

Stock/Inventory SQL #8

Genaker opened this issue Oct 12, 2021 · 0 comments

Comments

@Genaker
Copy link
Owner

Genaker commented Oct 12, 2021

SELECT main_table.*, cp_table.type_id FROM cataloginventory_stock_item AS main_table INNER JOIN catalog_product_entity AS cp_table ON main_table.product_id = cp_table.entity_id AND (cp_table.created_in <= '1630438980' AND cp_table.updated_in > '1630438980') WHERE (main_table.product_id IN('109340')) - > []

SELECT main_table.*, cp_table.sku, cp_table.type_id FROM cataloginventory_stock_status AS main_table INNER JOIN catalog_product_entity AS cp_table ON main_table.product_id = cp_table.entity_id AND (cp_table.created_in <= '1630438980' AND cp_table.updated_in > '1630438980') WHERE (main_table.product_id IN('109340')) AND (main_table.website_id = '0') - > []

SELECT e.*, stock_status_index.stock_status AS is_salable FROM catalog_product_entity AS e LEFT JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE ((e.entity_id = '109340')) AND (e.created_in <= '1630438980') AND (e.updated_in > '1630438980') - > []

SELECT e.*, price_index.price, price_index.tax_class_id, price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price, cat_index.position AS cat_index_position, stock_status_index.stock_status AS is_salable, links.link_id, links.product_id AS _linked_to_product_id, link_attribute_position_int.value AS position FROM catalog_product_entity AS e INNER JOIN catalog_product_index_price AS price_index ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' INNER JOIN catalog_category_product_index_store1 AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=2 LEFT JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 INNER JOIN catalog_product_link AS links ON links.linked_product_id = e.entity_id AND links.link_type_id = 1 LEFT JOIN catalog_product_link_attribute_int AS link_attribute_position_int ON link_attribute_position_int.link_id = links.link_id AND link_attribute_position_int.product_link_attribute_id = '1' INNER JOIN catalog_product_entity AS product_entity_table ON links.product_id = product_entity_table.row_id AND (product_entity_table.created_in <= '1630438980' AND product_entity_table.updated_in > '1630438980') WHERE ((e.entity_id NOT IN('109340')) AND (links.product_id in (81983)) AND (e.row_id != '81983')) AND (e.created_in <= '1630438980') AND (e.updated_in > '1630438980') ORDER BY e.sku ASC LIMIT 20

SELECT e.*, price_index.price, price_index.tax_class_id, price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price, cat_index.position AS cat_index_position, stock_status_index.stock_status AS is_salable FROM catalog_product_entity AS e INNER JOIN catalog_product_index_price AS price_index ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' INNER JOIN catalog_category_product_index_store1 AS cat_index ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=2 LEFT JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE ((e.entity_id IN(5690, 2513, 17711, 5174, 32798, 4790, 38782, 38788, 17612, 113135, 5140, 42506, 38779, 106283, 50338, 21245, 24160))) AND (e.created_in <= '1630438980') AND (e.updated_in > '1630438980') LIMIT 17

SELECT main_table.*, cp_table.type_id FROM cataloginventory_stock_item AS main_table
INNER JOIN catalog_product_entity AS cp_table ON main_table.product_id = cp_table.entity_id AND (cp_table.created_in <= '1630438980' AND cp_table.updated_in > '1630438980') WHERE (main_table.product_id IN('49996'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant