繁体   English   中英

以编程方式更新产品缩略图,小图像和基本图像

[英]update product thumbnail ,small image and base image programatically Magento

需要以编程方式更新产品缩略图,小图像和基本图像

为此,请使用以下代码

$collection1->addImageToMediaGallery($importDir,$mediaArray,false);

    //$collection1->setStoreId(0);
        $collection1->save();
if (isset($mediaGallery['images'])){
            //loop through the images
            foreach ($mediaGallery['images'] as $image){
            //set the first image as the base image
            Mage::getSingleton('catalog/product_action')->updateAttributes(array($collection1->getId()), array('image'=>$image['file'],'thumbnail'=>$image['file'],'small_image'=>$image['file']), 0);
            //stop
            break;
            }
            }

与此代码

图片添加到图库

但是我需要设置最新图像以设置为图像和基本图像

请提出我该如何实现这一感谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM