简体   繁体   English

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

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

need to update the product thumbnail , small image and base image programatically 需要以编程方式更新产品缩略图,小图像和基本图像

for this ia using a below code 为此,请使用以下代码

$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;
            }
            }

with this code a 与此代码

image adding to the gallery 图片添加到图库

but i need to set the latest image to set as image and base image 但是我需要设置最新图像以设置为图像和基本图像

.Please suggest how can i achieve this thanks 请提出我该如何实现这一感谢

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

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