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.

Related Posts

Mar 25, 2014
2 minutes

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.

Apr 4, 2014
2 minutes

Creating a Best-Sellers Category with Magento

Magento allows you to organize products in categories, and a single product can be a member of quite a few separate categories. As a result, you can create a category that is specifically for your top selling products. You could manually keep track of which products sell the best, either by number of sales completed, or by the actual quantity of each product that were sold. If you want to spend all your time managing this category, then this is the way to go. However, there is a much easier way to manage the products in the category.

Mar 28, 2014
2 minutes

Launching a Redesign of a Website

Over the last few months, I have been working on a major redesign of an existing Magento website. One of the major goals of the redesign was to take a legacy desktop-only website and upgrade it to take full advantage of Responsive Web Design so that customers could equally utilize mobile and desktop devices to browse and purchase products.

For a site that had seen only minor updates over the last 5 years, this redesign represented a major change visually and navigationally from the previous site. Based on the history of the site, the development team was optimistic that the redesign would be well-received, but were suprised by a few things that came up in the feedback we saw.