【发布时间】:2017-01-05 20:44:00
【问题描述】:
我有一个新的商店视图,我已经使用 magento 管理员更新了所有产品:**Manage Products > Select all > Update Attributes**,然后选择了新商店。现在我的所有产品都与我的新商店视图相关联,我的所有图像都有问题。在前端它显示所有占位符。在管理面板中,当我单击产品然后单击图像.. 它可能有图像,但未选择使用基本图像、小图像或缩略图。
有没有办法更新我的新商店视图上的所有图像以使用默认的商店视图主图像?
require_once 'abstract.php';
class Attach_Default_Store_Images Extends Mage_Shell_Abstract {
public function run()
{
$products = Mage::getModel('catalog/product')->getCollection();
foreach ($products as $product) {
$productFrom = $product->setStoreId(1)->getImage();
$productTo = $product->setStoreId(13)
->setImage($productFrom)
->setSmallImage($productFrom)
->setThumbnail($productFrom);
echo "Images Updated\n";
$product->save();
}
Mage::getModel('catalog/product_image')->clearCache();
echo "Image Cache Cleared\n";
}
public function usageHelp()
{
return <<<USAGE
Usage: php -f cache.php -- [options]
php -f cache.php -- clean
clean Clean Old Cache
help This help
USAGE;
}
}
$shell = new Attach_Default_Store_Images();
$shell->run();
运行上面的shell脚本?
【问题讨论】: