0

I'm export/importing products including the tier price to a CSV file:

foreach($products as $productid) {
    $existingTierPrice = $product ->load($productid)->tier_price;

    foreach($existingTierPrice as $key=>$value) {
        $tierarray = array("all","all",$value['price_qty'],$value['price']);
        print stripslashes(implode('^',$tierarray)) . "\n";
    }
}

This works great but what to do when a product has multiple tier prices?

So in other words, how can i use the above code and make sure multiple tierprices of a product get exported and the tierprices can be edited and imported again into Magento.

0

Please try bellow code

$productId = 1;
$product = Mage::getModel('catalog/product')->load($productId);
$insetTierPrice[] = array(
    'website_id' => 1,
    'cust_group' => Mage_Customer_Model_Group::CUST_GROUP_ALL,
    'price_qty'  => 2,
    'price'      => 2
);
$insetTierPrice[] = array(
    'website_id' => 1,
    'cust_group' => Mage_Customer_Model_Group::CUST_GROUP_ALL,
    'price_qty'  => 3,
    'price'      => 3
);
$product->setData('tier_price', $insetTierPrice);
try {
    $product->save();
} catch (Mage_Core_Exception $e) {
    $e->getMessage();
}
1
  • Thanks for this, but what i mean is how can i use my code and make sure multiple tierprices of 1 product get exported and the tierprices can ben edited and imported again into Magento
    – RoRo
    Nov 10 '15 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.