Magento的产品梯队价格的产品图片更新删除 [英] Magento product tier prices are deleted on product images update

查看:60
本文介绍了Magento的产品梯队价格的产品图片更新删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个脚本以编程方式更新自己的产品图片,但我的脚本删除

I have created a script to update programmatically my products pictures but my script delete all tier_prices on $product->save();

下面是我BILDER更新脚本:

Here is my bilder update script :

foreach ($productCollection as $product) {

    $formatted_sku = $product->getSku();
    $config = $product->getMediaConfig();



    // JPG files verification
    $jpg_file = $images_folder.$formatted_sku.".".$extension[0];
    if (file_exists($jpg_file) ) {
        $fileurl = $config->getMediaUrl($jpg_file);
        $product->addImageToMediaGallery($jpg_file, $visibility, false, false);
        $product->save();

    }
}

如何避免更新tier_prices?

How can I avoid the update of my tier_prices ?

非常感谢.

推荐答案

对于那些仍在运行到这个问题,有一个简单的解决尝试.它看起来像tierprice数据不会被默认getModel该产品读取.为了解决这个问题,只需要调用该产品的方法getTierPrice加载它.

For those of you that are still running into this issue, there is a simple fix to try. It looks like the tierprice data is not read by the default getModel for the product. To fix this, just call the product's getTierPrice method to load it.

$tp=$product->getTierPrice();

您不必做别的什么,只是加载它.然后,当你保存产品,分层定价数据被保存.

You don't have to do anything else, just load it. Then when you save the product, the tiered pricing data is saved.

这篇关于Magento的产品梯队价格的产品图片更新删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆