Magento - 显示非基础,小图像或拇指的图像

时间:2014-08-21 21:16:24

标签: magento

我想知道是否有办法显示不是base,small_image或thumb的产品图片。我有几百个生成的产品没有选择,所以我想显示一个图像,即使没有选择。

1 个答案:

答案 0 :(得分:0)

据我所知,你不应该尝试这种方法。

最佳解决方案是在您的数据库上运行脚本,并为没有这些产品的所有产品设置默认图像。

这是脚本:

# Brings all products with no standards images
SELECT * 
FROM catalog_product_entity_varchar 
WHERE entity_type_id = 4 
    AND attribute_id in (85,86,87) # base image = 85, small_image = 86, thumbnail = 87
    AND value = 'no_selection';

# update images
UPDATE catalog_product_entity_varchar t1
SET t1.`value` = (
    SELECT t2.`value` 
    FROM catalog_product_entity_media_gallery t2 
    WHERE t2.attribute_id = 88 AND t2.entity_id = t1.entity_id
    LIMIT 1)
WHERE t1.entity_type_id = 4 
    AND t1.attribute_id in (85,86,87) # base image = 85, small_image = 86, thumbnail = 87
    AND t1.`value` = 'no_selection';

干杯,