By default, Magento comes with many core functionalities & features that makes it perfect CMS for easy management of products as well as an enhanced e-commerce solution. Magento comes with a promotional tier price solution which is very helpful when you want to give discounts based on the quantity of the products that encourages customers to purchase more quantity. Magento displays tier price on both catalog pages as well as the product page just by adding quantity and price from the admin backend.
Recently, while working on one of the Magento stores, I came up with a situation to change tier price of all the store products. After a sip of coffee, I started coding and ended up with a small piece of code that will save my time as well as helped me to update tier price for products. So, today I would like to share the easiest way to set tier price programmatically in Magento.
All you need to do is pass the product ID and tier price to below code and it will work like a charm to set tier price programmatically for the product.
try { Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $Mytierprices[] = array( 'website_id' => 0, 'cust_group' => 1, 'price_qty' => 5, 'price' => 32 ); $product_id = 2; //PASS YOUR PRODUCT ID HERE $product = Mage::getModel('catalog/product')->load($product_id); $product->setTierPrice($Mytierprices); $product->save(); } catch (Exception $e) { echo $e->getMessage(); }
You can try and use this code according to your need of setting up tier price for one product or more than one products simply by customizing this code. You can feel free to ask any question regarding this code. Don’t forget to hit down stars and you can also get in touch with us on our social media for more blogs as well as extension updates.
Until that Happy Coding!
E-commerce has transformed the way consumers shop for products and services and interact with businesses.…
The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…
Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…
Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…
We're thrilled to announce the release of Hyvä Themes 1.3.6 and 1.3.7! These latest updates…
Your e-commerce platform is surging - orders are rolling in, traffic spikes are becoming the…
View Comments
Hi
I need to get tier price as table structure in product detail page and when the qty was changed respective price needs to be replaced in product detail page.