Magento - 设置“排除”的 SQL 命令在产品图片上
我想知道是否有一些我可以运行的 SQL 命令将任何只有 1 个图像的产品设置为从图像库中“排除”该图像。添加以下内容会将所有排除设置为 1(或勾选“排除”图像框,换句话说):
UPDATE catalog_product_entity_media_gallery_value
SET disabled = 1
但我只需要对具有 1 个图像的产品执行此操作,并将任何具有超过 1 个图像的产品“未排除” (或“禁用= 0”)。
Magento 版本是 1.4.2.0。
欢呼
更新:我发现以下内容正在做类似的事情,尽管我只想排除只有 1 张图像的产品:
-- 将所有图像设置为启用(取消选择“排除”)
update catalog_product_entity_media_gallery_value set disabled = 0;
-- 将所有主图像设置为禁用(选择“排除”),这样它们就不会出现在“更多视图”中
update catalog_product_entity_media_gallery_value set disabled=1 where value_id in (select value_id from catalog_product_entity_media_gallery where value in (select value
from catalog_product_entity_varchar where attribute_id=(select attribute_id from eav_attribute where attribute_code=’image’ and entity_type_id=4)))
I'm wondering if there's some SQL command I can run that will set any product with only 1 image to "exclude" that image from the image gallery. Adding the following will set all excludes to 1 (or tick the "exclude" image box in other words):
UPDATE catalog_product_entity_media_gallery_value
SET disabled = 1
But I need to only do that for products with 1 image, and leave any products with more than 1 image "un-excluded" (or "disabled = 0").
Magento version is 1.4.2.0.
Cheers
UPDATE: I found the following which is doing something similar, although I would want just products with only 1 image to be excluded:
-- Set all images as enabled ("exclude" deselected)
update catalog_product_entity_media_gallery_value set disabled = 0;
-- Set all the main images as disabled ("exclude" selected) so that they do not show up in “More Views”
update catalog_product_entity_media_gallery_value set disabled=1 where value_id in (select value_id from catalog_product_entity_media_gallery where value in (select value
from catalog_product_entity_varchar where attribute_id=(select attribute_id from eav_attribute where attribute_code=’image’ and entity_type_id=4)))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,这似乎可以解决问题:
OK, this seems to do the trick:
我建议您不要将其作为 SQL 运行,而是更改主题的
template/catalog/product/view/media.phtml
文件,以便仅在存在多个图像时才显示图库(我假设这就是您想要实现的目标??)。将下面的行从0
更改为1
这样做的好处是,您无需在每次添加新产品时重新运行 SQL 。
HTH,
京东
Rather than running this as SQL, I would recommend that you change your theme's
template/catalog/product/view/media.phtml
file so that it only shows the gallery if there is more than one image (I assume that's what you are trying to achieve??). Change the line below from0
to1
The advantage in doing it this way is that you won't need to re-run the SQL every time that you add a new product.
HTH,
JD