【发布时间】:2020-05-26 10:34:46
【问题描述】:
所以我有一个 SQL 查询,我在 Magento 2 数据库上运行。它成功列出了“状态”为“已禁用”(2) 且库存数量大于 0 的所有项目。
select
`eav_attribute`.`attribute_id` AS `attribute_id`,
`catalog_product_entity_int`.`entity_id` AS `entity_id`,
`catalog_product_entity_int`.`value` AS `value`,
`eav_attribute`.`attribute_code` AS `attribute_code`,
`catalog_product_entity`.`sku` AS `sku`,
`catalog_product_entity`.`type_id` AS `type_id`,
`cataloginventory_stock_item`.`qty` AS `qty`
from
(((`eav_attribute`
join `catalog_product_entity_int` on ((`eav_attribute`.`attribute_id` = `catalog_product_entity_int`.`attribute_id`)))
join `catalog_product_entity` on ((`catalog_product_entity_int`.`entity_id` = `catalog_product_entity`.`entity_id`)))
join `cataloginventory_stock_item` on ((`catalog_product_entity_int`.`entity_id` = `cataloginventory_stock_item`.`product_id`)))
where
((`eav_attribute`.`attribute_code` = 'status') and
(`catalog_product_entity_int`.`value` = 2)) and
(`cataloginventory_stock_item`.`qty` > 0 )
它适用于选择结果集,并为我提供符合这两个标准的准确项目列表。我将如何修改它以将此结果集中的项目的“状态”设置为“已启用”(1)。所以基本上,我只需要运行这些标准,然后对于每个结果,将列 catalog_product_entity_int.value 设置为 1 而不是 2。
【问题讨论】:
标签: mysql sql magento select magento2