Magento-如何为商品捆绑包显示相同的图像? [英] Magento - How to show the same images for product bundles?
问题描述
我按照Magento网站上的说明创建了捆绑产品,以使其具有多种尺寸.见附图:
I created a bundled product following the instructions on the Magento site to enable it to have several sizes. See attached image:
我想当我执行快速简单"产品创建时,它不会自动添加相同的图像.但是,由于该选项仅适用于大小,因此图像应该相同. 问题是,当我转到购物车或结帐页面或任何其他页面时,该产品没有图像.我的产品与尺寸相结合,可提供230多种产品,因此重新上传所有图像是一场噩梦.
I'm supposing that when I do the Quick simple product creation, it doesn't automatically add the same images. But since the option is only for size, the image should be the same. The problem is, when I go to the cart or checkout page or any other page, there is no image for the product. The combination of my products with the sizes, that s over 230 products, so re-uploading all the images is a nightmare.
问题是,我如何让系统将相同的图像用于所有不同的尺寸?
Question is, how can I have the system use the same image for all the different sizes?
谢谢.
推荐答案
可配置产品也有类似的问题.我希望将分配给主要产品的图像也添加到所有选项中.因此,我创建了一个扩展并观察了catalog_product_save_after事件.然后,我在观察者中添加了这种代码:
I had similar problem with configurable products. I wanted the image which I assign to the main product to be added also to all options. So I created an extension and observed catalog_product_save_after event. Then I added this kind of code in my observer:
$product = $observer->getEvent()->getProduct();
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)
{
$main_image = $product->getImage();
if($main_image != "no_selection")
{
$productTypeIns = $product->getTypeInstance(true);
$childIds = $productTypeIns->getChildrenIds($product->getId());
$importDir = Mage::getBaseDir('media') . DS . 'catalog/product';
foreach ($childIds as $childId)
{
foreach($childId as $_childId)
{
$childProduct = Mage::getModel('catalog/product')->load($_childId); //You get your child products here
if ($childProduct->getImage()=="no_selection")
{
$childProduct->addImageToMediaGallery($importDir.$main_image,array ('image','small_image','thumbnail'),false,false);
$childProduct->save();
}
}
}
}
}
这篇关于Magento-如何为商品捆绑包显示相同的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!