小编Fre*_*red的帖子

以编程方式为Store View(Magento)设置默认媒体库图像

我有一个脚本,可以将图像添加到我的产品中.它用于设置图像,small_image和缩略图.该代码适用于默认视图,但当我切换到商店视图时,媒体库设置为"no_image".导致我的产品在前端完全没有图像.

我试图重置商店视图属性但没有成功.

$product->addImageToMediaGallery($fileName, array('image', 'small_image', 'thumbnail'), false, false);
$attributes = $product->setStoreId(1)->getTypeInstance(true)->getSetAttributes($product);
if (isset($attributes['media_gallery'])) {
    $attributes['media_gallery']->getBackend()->clearMediaAttribute($product, array('image', 'small_image', 'thumbnail'));
}
$product->save(); 
Run Code Online (Sandbox Code Playgroud)

如何修改特定的商店属性,并将其重置为使用父属性?

谢谢.

php magento

8
推荐指数
1
解决办法
8914
查看次数

标签 统计

magento ×1

php ×1