Archive for November, 2010

Resolving Magento Extension Conflicts

Posted by: Karen Tuesday, November 23rd, 2010

 

What are extension conflicts?

One of the biggest problems we see as Magento matures is extension conflicts. This is where you have or more extensions effectively replacing the same core files in Magento. If you see an extension that uses the word “<rewrite>” in it’s config.xml file be aware that you may hit conflicts with other extensions.

There isn’t an easy way around extension conflicts. You could argue that better programming will work – e.g. by using Observers, taking advantage of source and backend models, writing your own MVC to sit alongside core Magento, etc. But my experience has shown that there are scenarios where you just need a re-write, especially where you are directly manipulating core functionality.

Many extensions will never have extension conflict problems. These include standard shipping extensions and payment modules. This is because the Magento architecture is such that they just plug in as an add-on – they aren’t interfering with the core code.

It’s worth pointing out that you may also get conflicts around the theme side, for instance if one extension replaces a step in one page checkout and another also does then you have isses. I’m concentrating here on PHP extension conflicts.

How do I identify extension conflicts?

There is a great extension(!) that will go through all your extensions looking for conflicts. This can be found here.

WebShopApps offer a modified version of this which works on Enterprise editions of Magento – we produced for a customer so thought may aswell release. More info here.

For theme conflicts there isnt a tool I know of to detect these, it comes down to good old concentration!

How do I resolve conflicts?

You have 3 choices for resolving conflicts:

  1. Merge the code from one conflicting file into another and switch off the rewrite config.xml in one
  2. Switch off the rewrite in one config.xml and then make the conflicting extension PHP file extend the other extension
  3. Use the <depends> capability to make one extension depend on another. They will then rewrite in that order

Which one you choose really does depend on how far you need to go. More often than not even though a class may conflict the actual methods within may not. In this scenario I’d go for option 3. If you have conflicting methods within classes then option 1 or 2 are applicable.

Example of option 2

So originally where you may have had something like:

class A_Extension_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage

You would change it to:

class A_Extension_Model_Type_Onepage extends B_Extension_Model_Type_Onepage

Once you have done this you need to change extension B config.xml file commenting out the conflicting “<rewrite>” blocks that are now inheriting from A.

Example of option 3

Let’s say you have 2 extensions Foo_A and Foo_B. In the module for file Foo_B (under app/etc/modules) you would add the following:

<depends Foo_A />

Now Magento will load the extensions in this order. So in effect the Foo_B class will be loaded first, then Foo_A, then base Magento.

Tiered Pricing on Configurable Products

Posted by: Karen Tuesday, November 23rd, 2010

How do configurable products calculate tiered prices?

A customer recently came to us with a query around configurable products and tiered pricing. Lets say, for simplicity, he was selling soap. A large soap and small soap are different prices. He wanted to configure tiered pricing on the soaps, with discounts for multiple purchases, but obviously the tiered prices differed across products.

Here’s the products we’ve created to demonstrate…..

 Product catalog

  

  

 Note the price difference between the large and small soaps. In addition to what’s shown here, we’ve entered a tier price of $3 each for 3 or more large soaps and $2.50 each for 3 or more small soaps. The ‘Soaps’ configurable product has a price tier of $4 each for 3 or more soaps. Lets take a look what happens at the checkout.

    

 

  

When we add a large and small soap to the cart, the price is taken from the configurable product (i.e. $6) not from the products themselves ($5 and $3 each). In fact every attribute of the product in the cart is taken from the configurable product and not the underlying simple product, except the attribute that is used to make it configurable (in this case it’s a new attribute we created called size).

How do grouped products deal with tiers?

However, if we create another product, this time a grouped product, we get a different result.

  Tiered prices come from the underlying products

The product page of the grouped product displays the prices and tiers taken from the underlying simple product. There are no prices or tiers set on the grouped product.

What do grouped vs configurable tiers look like in the cart?

Here’s what the grouped products look like in the cart (first two items), compared to the configurable products (second two items).

 Grouped and configurable products in the cart

Note the tiered prices are taken from the underlying simple product.

For more information on setting up tiered pricing in Magento see this Magento screencast

Thanks for reading.

What’s changed in Magento 1.4.2

Posted by: Karen Tuesday, November 16th, 2010

Changes that may affect us

The new 1.4.2 version of Magento Community has now been updated to a release candidate status, and will probably be live by the end of 2010. According to Magento, it’s mainly a bug fix release, but there are a few items that may affect our extensions.

One of the biggest changes in 1.4.2 is the new Magento Connect Manager. The extension key format has changed.
For example: magento-community/Webshopapps_Extension
needs to be changed to
http://connect20.magentocommerce.com/community/Webshopapps_Extension

We’ll be updating our community based extensions, available on Magento Connect, in the next few days.

The other major change we’ve flagged as affecting us is around shipping rate caching and calculation.

Which of our extensions are affected?

We have done some quick and dirty testing of some of our extensions, but we will perform further testing and officially sign off by end December 2010.

From our initial tests, these extensions appear to be compatible with Magento 1.4.2:

  • Table based shipping extensions, including Product Matrix, Premium Matrix Rate, Product Rate & Royal Mail
  • Freight Extensions including Conway Freight, Echo Freight and Estes Freight
  • Shipping Override
  • Tiered Pricing
  • Invoicing module

(We don’t recommend you run production installs of 1.4.2 with these extensions until further testing is complete)

Drop ship is our most complex extension and it will require some re-factoring to accommodate Magento 1.4.2. We expect to have a release out by early January 2011.

If there is an extension not covered here, please email us and we’ll let you know the status and when it should be confirmed.

Sample URL Links not working for Downloadable Products in Magento

Posted by: Karen Friday, November 12th, 2010

On www.webshopapps.com we want to show our documentation under the docs&demos tab. We are using the samples feature in Magento to do this – all our products are downloadable. 

We found using a URL link sometimes works and sometimes causes issues. This is due to Magento adding a level of abstraction that we don’t believe is required. It would do something like this: 

www.webshopapps.com/downloadable/download/sample/id/product/3.  Whereas we just want it to do: 

wiki.webshopapps.com 

I looked in the codebase and changed the file app/code/core/Mage/Downloadable/Block/Catalog/Product/Samples.php as follows: 

 
public function getSampleUrl($sample) {
    if ($sample->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_URL) {
          return $sample->getSampleUrl();  

     } else {

        return $this->getUrl(‘downloadable/download/sample’, array(‘sample_id’ => $sample->getId()));      

    }