【问题标题】:Magento Duplicate Group Price and Tier Price from one product to anotherMagento 将组价格和等级价格从一种产品复制到另一种产品
【发布时间】:2017-04-12 01:38:03
【问题描述】:

我已成功读取产品中的 Group Price 和 Tier Price 数组。

但我无法使用其他产品的数组设置 Group Price 和 Tier Price 属性。

这是读取 Group Price 和 Tier Price 数组的方式。

$groupPrices = $simpleProduct->getData('group_price');
if (is_null($groupPrices)) {
    $attribute = $simpleProduct->getResource()->getAttribute('group_price');
    if ($attribute) {
        $attribute->getBackend()->afterLoad($simpleProduct);
        $groupPrices = $simpleProduct->getData('group_price');
    }
}

我尝试了以下方法将它们设置为其他产品

$product->setGroupPrice($groupPrices);

$product->setData('tier_price', $tierPrices);

$product->setData('tier_price', $tierPrices)->getResource()->saveAttribute($product, 'tier_price');

他们都没有工作。请帮忙!

【问题讨论】:

    标签: magento


    【解决方案1】:

    查看层价格数组后,我发现有一个 price_id 键,当您将层价格数据从一个产品复制到另一个产品时,显然不应该使用并复制到另一个产品,因此您可以对数组进行切片,删除此键值对。

    (
        [0] => Array
            (
                [price_id] => 1285  // REMOVE THIS KEY-VALUE PAIR
                [website_id] => 0
                [all_groups] => 0
                [cust_group] => 1
                [price] => 7.0600
                [price_qty] => 2.0000
                [website_price] => 7.0600
            )
    
        [1] => Array
            (
                [price_id] => 1286  // REMOVE THIS KEY-VALUE PAIR
                [website_id] => 0
                [all_groups] => 0
                [cust_group] => 1
                [price] => 6.9100
                [price_qty] => 5.0000
                [website_price] => 6.9100
            )
    
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多