使所有商店图像成为Magento中的基本,小图像和缩略图? [英] Make all store images the base, small and thumbnail images in Magento?

查看:103
本文介绍了使所有商店图像成为Magento中的基本,小图像和缩略图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一家拥有约3,000种产品的Magento商店。几乎所有这些产品都附加了一个图像。

I have a Magento store that has around 3,000 products. Almost all of these products have a single image attached to it.

出于某种原因,即使我将小图像和缩略图设置为与基本图像相同导入CSV文件,仅为每个产品设置基本映像。这意味着当您搜索产品时,您会获得一个占位符 - 但是一旦您进入产品页面,您将获得正确的图像。这可以通过进入产品管理页面并选择小图像和缩略图的框来轻松解决。

For some reason, even though I set the small image and thumbnail image as the same as the base image in the import CSV file, only the base image is set for each product. This means that when you search for a product you get a placeholder - but once you go into the product page you get the correct image. This can be easily remedied by going into the product admin page and selecting the boxes for small image and thumbnail.

问题是,3000张图像需要很长时间时间做手动。我找到了一个SQL命令,应该使所有基本,小图像和缩略图图像映射每个产品的第一个图像。因为我每个产品只有一个图像,所以这应该是完美的。但是,它没有做任何事情。它表示0行已更改。

The problem is, with 3,000 images this would take quite a long time to do manually. I have found a SQL command that should make all base, small and thumbnail images map the the first image for each product. As I only have one image for each product this should be perfect. However, it doesn't do anything. It says 0 rows changed.

UPDATE catalog_product_entity_media_gallery AS mg,
catalog_product_entity_media_gallery_value AS mgv,
catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE  mg.value_id = mgv.value_id
AND mg.entity_id = ev.entity_id
AND ev.attribute_id IN (70, 71, 72)
AND mgv.position = 1

有谁知道为什么这不起作用?

Does anyone know why this isn't working?

谢谢,

Danny

推荐答案

对数据库进行类似的更改后,即使成功,也需要在缓存管理中重建图像缓存。

After making a change like that to the database, even if successful, you would need to rebuild the images cache in Cache Management.

您可以使用这样的脚本来完成它,而不用担心缓存或索引。

You might be able to do it with a script like this and not worry about caching or indexing.

<?php

require 'app/Mage.php';
Mage::app();

$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product) {
    if (!$product->hasImage()) continue;
    if (!$product->hasSmallImage()) $product->setSmallImage($product->getImage());
    if (!$product->hasThumbnail()) $product->setThumbnail($product->getImage());
    $product->save();
}

?>Done!

将此保存在您的Magento目录中,并通过在浏览器的地址栏中输入URL来访问它。我还没有测试过这个脚本。

Save this in your Magento directory and access it by typing the URL into your browser's address bar. I haven't tested this script yet.

这篇关于使所有商店图像成为Magento中的基本,小图像和缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆