How is a product collection widget rendered on a CMS page?

See the beginning here: How is a widget rendered on a CMS page





The $value (the function’s result) looks like this:





The function’s result looks like this:











How does the \Magento\Rule\Model\Condition\Sql\Builder::_joinTablesToCollection() work?



$out looks like this:

(IFNULL(`e`.`entity_id`, 0) IN (SELECT `catalog_category_product`.`product_id` FROM `catalog_category_product` WHERE (category_id IN ('3')))) 


The $collection's SQL looks like this:

SELECT 
	`e`.*, `cat_index`.`position` AS `cat_index_position`
	, `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` 
FROM 
		`catalog_product_entity` AS `e`
	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='3'
	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 = '2' 
WHERE (((IFNULL(`e`.`entity_id`, 0) IN (
	SELECT `catalog_category_product`.`product_id` 
	FROM `catalog_category_product` 
	WHERE (category_id IN ('3'))
))));



See also: