Magento Tier Prices for Configurable Products

The way Magento handles tier prices related to configurable products is a little bit strange. Assuming we have a basic T-Shirt which is available in red and blue and normally costs 10 Euro. If you purchase 10 or more shirts, the price is only 9 Euro. I (and many others of you out there, too!) would expect to get the cheaper price if you buy e.g. 6 blue and 4 red shirts. Anyways, this is not the case in Magento. In order to achieve this behaviour, the guys from Tridian wrote a nice piece of code. Unfortunately, it seems to be old and unsupported. So I updated the script to Magento 1.4.1.1 and removed a little bug. The script from Tridian works fine for configurable products that have tiering prices. Sadly, there are problems with configurable products that do not have tier prices but a special price. In my version below, this bug is fixed.

Basically, the module rewrites the class Mage_Catalog_Model_Product_Type_Configurable_Price and the method getFinalPrice($qty=null, $product) in that class. If the given product has tiering prices configured, the new method calcConfigProductTierPricing($product) is called. This method generally does the following:

  1. gets all items from the quote
  2. iterates over all these items
  3. creates an array mapping the sku of the current item to the quantity
  4. gets the entry at the base products sku
  5. sums up all quantities
  6. calculates the tier price with the computed quantity and the parent product

The reason why this does the job is that the items collection in the quote has instances of the parent and the child product.

UPDATE March 12, 2012:
The above information explaining how the extension works is outdated. The extension development has been moved to GitHub. You can also download the latest version from there. Anyway, the extension is also available on Magento Connect.

If you use and like the extension, I am happy to read your comment or message.
If you have any problem with the extension, please open an issue on GitHub.

Dieser Beitrag wurde unter Magento, PHP veröffentlicht. Setze ein Lesezeichen auf den Permalink.

36 Antworten auf Magento Tier Prices for Configurable Products

  1. TopOSScz sagt:

    Great extension, I thank you. ;-)

  2. TopOSScz sagt:

    I fixed one bug:

    if($product->getTierPriceCount() > 0) {
    $tierPrice = $this->calcConfigProductTierPricing($product);
    if($tierPrice < $finalPrice)
    $finalPrice = $tierPrice;
    }
    if($tierPrice this condition resolve lower special price then tier price.

  3. TopOSScz sagt:

    Better condition:
    if($tierPrice > 0 && $tierPrice < $finalPrice)

  4. toulousain sagt:

    Good extension.

    But i have a problem when configurable product haven’t tier price and attribute have a lower price (ex -10$). So the price in cart isn’t good.
    To fix my bug i have modified the code in getFinalPrice function :
    New code :
    $product->setFinalPrice($basePrice);
    Old code :
    $product->setFinalPrice($finalPrice);

    Sorry for my english, i’m french !!

    • Simon sagt:

      Thanks for your feedback. Unfortunately, I do not exactly understand the problem, so that I am not able to reproduce it. Anyway, if more of you have this problem, just explain it again and I will fix it.

  5. dijoga sagt:

    Thank you so much for this extension – seems to work exactly as I need it!!!

  6. Tim D sagt:

    This works perfectly! Needed this for quite some time. Thanks a bunch!!

  7. Finn Nielsen sagt:

    This looks like the thing I am missing. It works perfectly for me.
    Is it possible to add a line to make notice on the discount?
    Like ” Normal price xx.xx quantity discount xx.xx”?

    • I think this is not an easy task. You will have to extend the price template under app/design/frontend/interface/theme/template/catalog/product/price.phtml…
      Sorry, but I do not have the time to dig deeper into the topic right now…

  8. Shafraz sagt:

    Is this possible to apply to the simple products?

  9. Carl sagt:

    An excellent extension. Very needed.

    I am on 1.6.1 and i am wondering how i get this to work. I have manually copied all the files to their respective directories as they are in the zip file. Do i need to do anything more because it is not working as planned.

  10. Coen sagt:

    Tested your extension and work perfectly in 1.6.1

    Great work and saved me a lot of time

    Thanks

  11. Callum sagt:

    I installed this module on Magento 1.4.2 and it does the job perfectly. It has improved the shopping experience for my customers and may have increased sales as well. Thank you very much for making it available to us!

    But I am experiencing a strange problem with configurable product pricing, and I need to know whether this module is the problem or whether the problem is with Magento 1.4.2.

    Let’s say I have a configurable product with two sizes: Small & Large. I set the Large size to be $5 more (+5$). This displays on the product page.

    When I put the Large size into the shopping cart, it doubles the additional cost. So instead of being $5 more than the Small size, it becomes $10 more once it’s in the cart.

    It works for negative pricing too. Now, let’s say the Small size is $2 less (-$2). When you put the Small size into the shopping cart, the price becomes $4 less.

    So it multiples the variable pricing (+/- amount) by a factor of 2. I have searched for hours on the Internet to see if this is a problem with Magento 1.4.2. I haven’t found any reference to this problem so now I wonder if it is caused by this module.

    Do you know if this problem is possibly caused by the module? How could I temporarily disable your Spranks module so that I can test if it is the problem or not?

    Thanks in advance for your advice.

    • Open the file app/etc/modules/Spranks_ConfigurableTierPrices.xml, change the “true” to “false” and refresh the cache. Then, check if the problem still exists.
      I can not imagine that my module causes this issue, but who knows…

      • Callum sagt:

        I followed your directions and I’ve confirmed that the problem is caused by the Spranks module.

        First, I disabled the Spranks module and then tested the variable pricing for a configurable product. It worked perfectly (as normal.)

        When I enabled the Spranks module again, the problem came back. Basically, the Spranks module will double any variable pricing (+/- price) for configurable products.

        Can you provide a fix for this problem?

  12. Matt sagt:

    Callum – we noticed the same thing on our site. After some detective work, we determined that it was only happening to products that had no tiers. So, for the time being, what we did was just add tiers to any configurable products without them, and that solved the problem for us until a proper fix can be made.

    • Callum sagt:

      Matt, thanks for the info. That’s an interesting discovery, but in my case, all my configurable products already have tiers … so this won’t work for my installation (1.4.2). =(

      • Matt sagt:

        Sorry I couldn’t have been more helpful, mate. We are running a different installation (1.9.1) so I’m sure that plays into it. We’ve since switched to a new module because we need tiers across both configurable and grouped products.

        Good luck to you!

  13. chris sagt:

    are you ever going to move on from beta version?

  14. Ravi sagt:

    Hi, I installed the extension (I am running 1.7) but something happened to my product prices index. I get the error, cannot run indexor after I installed. Can you please provide a suggestion to help me fix it?

    Thanks

    • Hi Ravi,

      I am sorry, but I do not have a glue which problem you have. It is quite unlikely that it has something to do with my extension. Anyway, if you really think it is a problem with my extension, open a bug with a detailed bug description on Github.

      Cheers
      Simon

  15. jcuenin sagt:

    Hi, my client was looking for this functionality, so thank you for solving my problem :)

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>