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`, `links`.`link_id`, `link_attribute_position_int`.`value` AS `position`, `cataloginventory_stock_status`.`stock_status` 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.website_id = '1' AND price_index.customer_group_id = 0
INNER JOIN `catalog_category_product_index` 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'
INNER JOIN `catalog_product_link` AS `links` ON links.linked_product_id = e.entity_id AND links.link_type_id = 4
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 = '4'
INNER JOIN `cataloginventory_stock_status` ON cataloginventory_stock_status.product_id = e.entity_id WHERE (e.entity_id NOT IN((SELECT `sales_flat_quote_item`.`product_id` FROM `sales_flat_quote_item` WHERE (quote_id = '')))) AND (links.product_id = 5052) AND (`e`.`entity_id` != '5052') AND (`cataloginventory_stock_status`.`stock_status` = 1) ORDER BY `cataloginventory_stock_status`.`qty` desc, `e`.`created_at` desc LIMIT 12
SELECT `e`.*, `idx_table`.`product_id`, `idx_table`.`store_id` AS `item_store_id`, `idx_table`.`added_at`, `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`, `cat_index`.`visibility`, `store_cat_index`.`visibility` AS `store_visibility`, `cataloginventory_stock_status`.`stock_status` FROM `catalog_product_entity` AS `e`
INNER JOIN `report_viewed_product_index` AS `idx_table` ON (idx_table.product_id=e.entity_id) AND (idx_table.visitor_id = '15446928')
INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.category_id = '2'
LEFT JOIN `core_store` AS `store_index` ON store_index.store_id = idx_table.store_id
LEFT JOIN `core_store_group` AS `store_group_index` ON store_index.group_id = store_group_index.group_id
LEFT JOIN `catalog_category_product_index` AS `store_cat_index` ON store_cat_index.product_id = e.entity_id AND store_cat_index.store_id = idx_table.store_id AND store_cat_index.category_id=store_group_index.root_category_id
INNER JOIN `cataloginventory_stock_status` ON cataloginventory_stock_status.product_id = e.entity_id WHERE (idx_table.product_id NOT IN('5052')) AND (cat_index.visibility IN(3, 2, 4) OR store_cat_index.visibility IN(3, 2, 4)) AND (`cataloginventory_stock_status`.`stock_status` = 1) ORDER BY `cataloginventory_stock_status`.`qty` desc, `e`.`created_at` desc