Saving Products in Magento Deletes Tier Pricing

Magento’s framework makes many things simple to accomplish when working with the products and categories of your eCommerce website. However, I have found one scenario that doesn’t exactly work as expected.

Tier Pricing in Magento

Magento allows you to setup custom pricing levels based upon the quantity purchased. You set the minimum quantity purchased to enable the lower price when the part is added to the customer’s cart. You could see where losing the tiered pricing for an entire catalog of products would be a big deal for a site.

Saving Products

The way I ran across this issue was to load all of the products for a particular category, remove the a category from the list of categories for the product, and then save the product. When I simply performed these steps, all tiered pricing would disappear. In order to combat this, I tried to load tiered prices for the product before saving, but this only caused database errors on save, as Magento was trying to duplicate the tiered pricing settings. The same happened if I loaded the tiered pricing separately, saved the product, and then add the tiered pricing back to the product before saving it again.

Properly Saving Category Changes for Products

One of the ways that I was able to find to properly add a product to a category and set the position in the category is to use the following:

$cat_api = new Mage_Catalog_Model_Category_Api;
$cat_api->assignProduct($categoryId, $productId, $position);

It turns out that the Mage_Catalog_Model_Category_Api class also has a function, removeProduct($categoryId, $productId); that will properly remove a product from a category programmatically without affecting the tiered pricing configuration for the product. While this does work, you should be aware that modifying products in this manner is not a fast process, and will take quite a while even for a few products.

comments powered by Disqus

Related Posts

301 Redirecting in Varnish

In Magento, you can set your secure and non-secure URLs explicitly. This works as expected in most cases, but can cause some issues when you have to specify full URLs or need to make any AJAX requests. When using the Nexcess Turpentine extension to enable Magento and Varnish to work together and you wish to only support traffic at www.example.com and not example.com, you would need to enable the setting in the Turpentine module to normalize the host.

Read More

Magento Cache with Cache Disabled

One of the things that I find quite annoying with a web platform is when you configure it to do one thing, and it does something different. Magento is an eCommerce software platform that many of the leading eCommerce websites use for their web stores. Magento Magento comes in two different flavors, a paid enterprise edition as well as a open-source community edition. The enterprise edition allows you to utilize the built-in full-page caching mechanism, while the community edition does not include a full-page caching solution.

Read More

Login Problems with Magento and Varnish

When you have a Magento website configured to use Varnish as a caching frontend, there are certain scenarios where you may have some problems logging-in to the frontend of the website. It poses some unique problems that are not frequently seen on a typical website. This issue typically manifests itself to the end user by visiting the login page, entering the correct credential, submitting the form, and then the page reloads the login page again instead of redirecting to the My Account page or whatever page is specified in the configuration.

Read More