Magento checkout agreements missing

Magento I had to work on a Magento template that was bought and assumed to be in a “fully functional and anatomically correct form” (cit), except that it was not able to show the checkout agreements in the checkout process even if the standard procedures are all done correctly.

The problem was (of course) in the XML layout of the checkout page (checkout.xml) where the block that was supposed to output the agreements, here below:

<block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>

Was positioned in the wrong place, in my case it was inside the “Review” element of the checkout:

<block type="checkout/onepage_review" name="checkout.onepage.review" as="review" template="checkout/onepage/review.phtml">
-- stuffs --
</block>

That is pretty wrong! This error will make impossible for customers to complete the checkout process as the system will spam pop “Hey you did not accept the agreements!”. That block is supposed to stay inside the info block of the review:


<block type="checkout/onepage_review_info" name="root" output="toHtml" template="checkout/onepage/review/info.phtml">
-- many stuffs --
   <block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
</block>

At this point a simple cache refresh fixed the issue and get the checkout agreements in the checkout page.

Enjoy!

Magento headers already sent

MagentoSometime while working with Magento, especially while browsing the site with Google Chrome, you may get the following error:

Duplicate headers received from server
The response from the server contained duplicate headers. This problem is generally the result of a misconfigured website or proxy. Only the website or proxy administrator can fix this issue.
Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple Content-Disposition headers received. This is disallowed to protect against HTTP response splitting attacks.

This will be fixed in Magento 1.7.x, but until then, if you like to fix it you need to duplicate a core file in the app/code/local/ folder modifying few lines.

The file you need is app/code/core/Mage/Core/Controller/Varien/Action.php, and you need to modify the method _prepareDownloadResponse, in particular this code:


$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Pragma', 'public', true)
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
->setHeader('Content-type', $contentType, true)
->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength)
->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"')
->setHeader('Last-Modified', date('r'));

into:


$this->getResponse()
->setHttpResponseCode(200)
->setHeader('Pragma', 'public', true)
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
->setHeader('Content-type', $contentType, true)
->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)
->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"', true)
->setHeader('Last-Modified', date('r'), true);

As said before, you have to duplicate this file before modifying, messing with the core files is always bad!
Your new file will be /app/code/local/Mage/core/Controller/Varien/Action.php.

If you plan to upgrade to Magento 1.7.x keep in mind that it is better to remove this patched file!

Enjoy!

Magento store and website information

MagentoIf you need to get information about the current store, or storeview or website, you may find handy the following small snippets:

Mage::app()->getStore()->getId()
Will give you the Store ID, easy uh?

Mage::app()->getStore()->getName()
Will give you the Store View Name.

Mage::app()->getStore()->getGroup()->getName()
Will give you the Store Group Name.

Mage::app()->getWebsite()->getName()
Will give you the Website Name.

Small & handy.

I use this stuff a lot while working on custom themes or some special integration processes on custom ad hoc modules.

Enjoy!

What e-commerce do you use?

Hello everyone,
I’m curious about that, I work on many kind of e-commerce platforms, what do you use?

Magento google sitemap generation for multistore installation

MagentoHello everyone,
if you ever need to have a sitemap for each store created under a single Magento installation, you will probably face a little error about the unavailability of your specified path for the creation of the sitemap.

Regardless of the path you may specify, you will get the following error all the time:

“Path “yourpath/yoursitemap.xml” is not available and cannot be used.”

As you can imagine the problem is not very clear as the error is misleading to a different source.

As today (Magento 1.6.x) the only way to avoid the problem, without touching core files that is, is to understand that Magento want a specific name for the sitemap, and it will not accept anything else:

sitemap.xml

However, to have more sitemap.xml, one for each storeview, you will need to manage sub-paths, like:

yourrootfolder/sitemaps/yourstoreview_[1,2,3...,n]/sitemap.xml

If you would like a clean approach you can, however, work with the rewrites to let the Apache serve a clean url for the sitemap:


RewriteCond %{HTTP_HOST} ^.*yourstore_1\.com$
RewriteRule ^sitemap.xml$ yourpath/sitemap.xml [NC]

Enjoy!

P.S.:

Also available in dutch!
http://www.byte.nl/blog/2012/08/10/sitemap-maken-in-een-multistore-magento/
http://www.dutchento.org/sitemap-maken-in-een-multistore-magento/#more-3555