13

In short: Retrieving a product URL with additional params doesn't work in CE 1.8 & EE 1.13.

URLs have changed with the latest version of Magento. Previously in CE 1.7 and EE 1.12 calling $this->getAddToCartUrl($_product) from a product list would run through the following stages:

  1. Mage_Catalog_Block_Product_Abstract::getAddToCartUrl()
    • Here it would add the query param "options" with the value "cart"
  2. Mage_Catalog_Block_Product_Abstract::getProductUrl()
    • This method essentially gets a value from the URL model
  3. Mage_Catalog_Model_Product_Url::getUrl()
    • A lot of processing occurs until the URL is finally generated, complete with the query parameters originally passed in

Now, with CE 1.8 and EE 1.13, step 3 Mage_Catalog_Model_Product_Url::getUrl() starts like this:

$url = $product->getData('url');
if (!empty($url)) {
    return $url;
}

Because the products in the list have URL data already, the query parameters are not added and the final URL does not contain ?options=cart.

My question: Is this a bug or a feature?

  • Just a side note, we have to add a form_key tag to our add to cart url after a couple of EE1.13 upgrades – brentwpeterson Oct 10 '13 at 22:24
  • Thanks for the input - by the looks of it Magento will do this automatically in Mage_Catalog_Block_Product_Abstract::getAddToCartUrl() via the core/session singleton. Can you give me an example of the code you used? – jharrison.au Oct 10 '13 at 22:29
3
+50

Wow, quite the delta for that class from 1.7.0.2 -> 1.8.0.0! Whereas there are substantial changes this class, and that this is "breaking behavior", it should be considered a bug and should be submitted to EE support.

There is nothing exceptionally novel or edgy about this previously-valid functionality, and even in a minor version update breaking changes should not exist (hence Magento 2).

  • Thanks Ben, just wanted to make sure I wasn't missing something. – jharrison.au Oct 20 '13 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.