Magento 2 - 从数据库更改图像角色

Magento 2 - Change image role from DB

我需要根据这些要求更改图像角色(small、thumb、swatch、base):

基本图像必须采用样本图像中存储的值

我发现数据库 table 是 catalog_product_entity_varchar,它由以下列组成:

"attribute_id" 其中包含属性的id:

"entity_id" 其中包含产品的 ID

"value" 包含图像的路径。 即“/A/1/A1L6ON14_Timberland_T-Shirt_a_Maniche_Corte_Rosso-Z_1.jpg”

我需要一个查询 从“attribute_id”=154 中复制列“value”,仅当“entity id”=xxx 的列“attribute_id”=87 时 (通过这种方式,我可以仅针对唯一产品测试查询)

和执行相同操作的查询,但总体上 table(没有指定的实体 ID)。

这里是解决方案:

更新 catalog_product_entity_varchar e1, catalog_product_entity_varchar e2 设置 e1.value = e2.value 其中 e1.entity_id = e2.entity_id 且 e1.attribute_id = 87 且 e2.attribute_id = 154 且 e1.store_id = 32 且 e2.store_id = 32;

更新 catalog_product_entity_varchar e1, catalog_product_entity_varchar e2 设置 e1.value = e2.value 其中 e1.entity_id = e2.entity_id 且 e1.attribute_id = 87 且 e2.attribute_id = 154 且 e1.store_id = 33 且 e2.store_id = 33;

更新 catalog_product_entity_varchar e1, catalog_product_entity_varchar e2 设置 e1.value = e2.value 其中 e1.entity_id = e2.entity_id 且 e1.attribute_id = 87 且 e2.attribute_id = 154 且 e1.store_id = 0 且 e2.store_id = 0;