【问题标题】:Magento disable products with no imagesMagento 禁用没有图像的产品
【发布时间】:2013-07-02 12:28:41
【问题描述】:

我正在尝试禁用许多在我的 Magento 安装中没有图像的产品。

以下 SQL 查询应该获取所有没有图像的产品,但我需要一种方法将所有没有图像的产品设置为禁用状态?

SELECT * FROM catalog_product_entity_media_gallery
        RIGHT OUTER JOIN catalog_product_entity
            ON catalog_product_entity.entity_id = talog_product_entity_media_gallery.entity_id 
   WHERE catalog_product_entity_media_gallery.value is NULL

【问题讨论】:

    标签: mysql sql magento


    【解决方案1】:

    我将它用于 magento 2.2.3

    更新 catalog_product_entity_int m left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id 设定值 = 2 在哪里 a.attribute_code = '状态' 和 m.entity_id 在 ( 选择 m.entity_id 来自 catalog_product_entity m 左加入catalog_product_entity_media_gallery_value_to_entity a 在 a.entity_id = m.entity_id 其中 a.value_id 为空 ) ;

    【讨论】:

      【解决方案2】:

      这是您要寻找的 Kode:

      -- here you set every one as DISABLED (id 2)
      UPDATE catalog_product_entity_int SET value = 2 
      -- here you are change just the attribute STATUS
      WHERE attribute_id = 4
          -- here you are looking for the products that match your criteria
          AND entity_id IN (
              -- your original search
              SELECT entity_id 
              FROM catalog_product_entity_media_gallery
              RIGHT OUTER JOIN catalog_product_entity ON catalog_product_entity.entity_id = catalog_product_entity_media_gallery.entity_id 
              WHERE catalog_product_entity_media_gallery.value is NULL
          );
      

      【讨论】:

        【解决方案3】:

        这显然适用于任何其他属性,因此只需根据需要更改代码。

        enabled = 1
        disabled = 2
        
        UPDATE catalog_product_entity_int cpei, catalog_product_entity cpe
        SET cpei.value = "2"
        WHERE cpe.entity_id = cpei.entity_id
        AND cpe.sku LIKE '%SKU%'
        AND cpei.attribute_id = 273
        

        也可以参考详情Document link

        如果我能进一步帮助你,请告诉我

        【讨论】:

        • 我仍然不确定查询是什么,我不想尝试,因为我很可能会弄乱数据库
        • 如果可能的话先备份然后试试:(
        • @KodeMatt 你在生产环境中这样做会很疯狂,这就是为什么你有一个开发版本。
        【解决方案4】:

        我稍微修改了一下,这对我有用

        删除 WHERE attribute_id = 4 并将 SELECT entity_id 更新为 SELECT catalog_product_entity.entity_id

        UPDATE catalog_product_entity_int SET value = 2 
        WHERE entity_id IN(
                SELECT catalog_product_entity.entity_id 
                FROM catalog_product_entity_media_gallery
                RIGHT OUTER JOIN catalog_product_entity ON catalog_product_entity.entity_id = catalog_product_entity_media_gallery.entity_id 
                WHERE catalog_product_entity_media_gallery.value is NULL
            );
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-07-14
          • 2014-12-31
          • 1970-01-01
          • 2014-01-01
          • 1970-01-01
          • 2012-05-07
          • 1970-01-01
          相关资源
          最近更新 更多