Magento – How to remove Tier Price programatically in Magento 1.9

deletemagento-1.9tierprice

I want to update tier price for a simple and configurable product. I have only one type of tier price with

  • Customer Group – Wholesale,
  • Qty – 1,
  • Price -10

Now I want to update tier price and for that first, I need to delete tier price of the product.

Can anyone help me in updating and deleting of tier price programmatically in Magento?

Best Answer

I am going to point to towards something without elaborating too much as I can't remember all of the details - I achieved this using the Magento SOAP API - so if you go into the SOAP API files Model and look how Tier pricing is handled in app/code/core/Mage/Catalog/Model/Product/Api.php then it should give you some idea.

I believe you can update and delete tier pricing via the product object by loading an array of all tiered prices. For the ones you want to remove, pass through qty as 0.

I remember testing a long time ago using the soap API - so please make sure you test and check what impacts it has in the database.

Here's a sample structure in JSON - first tier price should be removed, the second should be created/updated:

"tier_price":[{
                   "customer_group_id":"0",
                   "website":"0",
                   "qty":"0",
                   "price":"15.99"
              },       
              {
                   "customer_group_id":"1",
                   "website":"0",
                   "qty":"50",
                   "price":"12.90"
               }
]

I remember testing a long time ago using the soap API - so please make sure you test and check what impacts it has in the database.

Sorry I can't be of more assistance!

Related Topic