sql Miva - 主产品代码中的所有变体

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql Miva - 主产品代码中的所有变体相关的知识,希望对你有一定的参考价值。

/*
	SELECT *
	FROM s01_ProductVariants pv
	LEFT JOIN s01_Attributes a
		ON pv.attr_id = a.id
	LEFT JOIN s01_Options o
		ON pv.option_id = o.id
	LEFT JOIN s01_ProductVariantParts pvp
		ON pv.variant_id = pvp.variant_id
	LEFT JOIN s01_Products p
		ON pvp.part_id = p.id
	LEFT JOIN s01_InventoryProductCounts ipc
		ON p.id = ipc.product_id
	LEFT JOIN s01_ProductImages pi
		ON p.id = pi.product_id AND pi.type_id = 1
	LEFT JOIN s01_Images i
		ON pi.image_id = i.id
	WHERE pv.product_id = (SELECT id FROM s01_Products p WHERE p.code = 'MASTER_PRODUCT_CODE');
*/


SELECT
	pv.product_id AS 'master_product_id',
	pvp.part_id AS 'variant_product_id',

	a.type AS 'attribute_type',
	a.code AS 'attribute_code',
	a.prompt AS 'attribute_prompt',

	o.code AS 'option_code',
	o.prompt AS 'option_prompt',
	o.image AS 'option_image',

	p.code AS 'variant_product_code',
	p.name AS 'variant_product_name',
	p.price AS 'variant_product_price',
	p.cost AS 'variant_product_cost',
	i.image AS 'variant_product_image',

	ipc.inventory AS 'variant_product_inventory'
FROM s01_ProductVariants pv
LEFT JOIN s01_Attributes a
	ON pv.attr_id = a.id
LEFT JOIN s01_Options o
	ON pv.option_id = o.id
LEFT JOIN s01_ProductVariantParts pvp
	ON pv.variant_id = pvp.variant_id
LEFT JOIN s01_Products p
	ON pvp.part_id = p.id
LEFT JOIN s01_InventoryProductCounts ipc
	ON p.id = ipc.product_id
LEFT JOIN s01_ProductImages pi
	ON p.id = pi.product_id AND pi.type_id = 1
LEFT JOIN s01_Images i
	ON pi.image_id = i.id
WHERE pv.product_id = (SELECT id FROM s01_Products p WHERE p.code = 'MASTER_PRODUCT_CODE');

以上是关于sql Miva - 主产品代码中的所有变体的主要内容,如果未能解决你的问题,请参考以下文章

sql Miva Merchant - 选择特定产品和图像类型的所有生成图像

xml Miva - 订购商品:主码的变体代码

xml Miva - 将所有产品自定义域代码加载为成员名称

html 最近浏览的项目功能。所有自定义Miva代码,不由模块运行。它存储产品代码列表,最多显示12个

xml Miva - 在商店中加载所有产品

PHP+MySQL 中的前端产品变体?