Some time its very difficult to update all products group price individually from admin of magento. Today i will show how to update it programmatically simultaneously.
<?php require_once 'app/Mage.php'; Mage::app(); ... $file = 'group-price.csv'; $csv = new Varien_File_Csv(); $data = $csv->getData($file); foreach ($data as $value) { $sku = $value[0]; $product = Mage::getModel('catalog/product')->setStoreId(0)->load(Mage::getModel('catalog/product')->getIdBySku($sku)); if ($product == false || !$product->getSku()) { continue; } //delete existing records if any $product->setData('group_price',array()); $product->save(); //create array for new customer price group $new_price = array( array ('website_id'=>0, 'cust_group'=>$value[1], 'price'=>$value[2]), array ('website_id'=>0, 'cust_group'=>$value[3], 'price'=>$value[4]) ); //Add new customer group price $product->setData('group_price', $new_price); $product->save(); } echo "Group price update successfully."; ... ?>
Steps:
1. Create an excel file and save as “group-price.csv” or any you wish.
2. IMP: on first row in sheet “sku” column name should be there, as shown in image. and remaining column you can give any name.
3. Upload csv file to root path of magento on server.
4. Create a file “group-price.php” and add code as shown above and upload to root of magento.
5. Run the url www.yourdomain.com/group-price.php. Voila!! all the products group price updated. You can check in any Product > Price tab there you will see two price with base price.
Here important point to remind you can use the website_id, storeid for which products you are going to update.
©2021. All rights reserved. Terms of Use | Privacy Policy
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
I am not able to save the group price. code just deleted any previous group price but did not update new group price
I fixed this issue. But got new issue.. I want to update existing group price without deleting previous group price. it should match group price and if there is group price present then do nothing else it should update it
Hey Ashutosh,
Above post is for updating group price, if you want your way you can customise using a condition before update.