Magento-从第三方XML文件导入图像 [英] Magento - importing images from a 3rd party XML file
问题描述
我想知道如何从第三方XML提要中上传图像以用作产品图像吗?
I am wondering how I'd upload images from a 3rd party XML feed to use as a products images?
我已经看到了addImageToMediaGallery()的用法,但是我不确定我需要做什么.
I've seen the use of addImageToMediaGallery() but I am unsure what I'd need to do.
我的假设是:
1)我需要将所有图像从XML feed中下载到一个文件夹中 2)将图像路径传递到addImageToMediaGallery方法中,并设置图像,small_image和缩略图 3)调用此方法
1) I will need to download all the images to a folder from my XML feed 2) Pass the image path into the addImageToMediaGallery method and set the image, small_image and thumbnails 3) call this method
谢谢
推荐答案
好,所以我的解决方案是使用cURL下载图像,然后将其保存到:
Ok, so my solution was to download the images using cURL and then save them to:
媒体/导入
media/import
然后我可以使用以下内容:
Then I could use the following:
$product->addImageToMediaGallery(Mage::getBaseDir('media') . DS . 'import/' . $filename, array('image', 'small_image','thumbnail'), false, false);
$ filename是服务器上映像的文件名.
Where $filename is the filename of the image on the server.
感谢所有看过的人!
这篇关于Magento-从第三方XML文件导入图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!