Categories


Archives


Recent Posts


Categories


Magento Giveth, then Magento Taketh

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

I had a client who was using the “store code in URL” feature of Magento throughout their site. This was working well for them, but there were a few URLs where they wanted NO store code, and I was asked to look into it.

Digging deep into the URL generation code, I discovered the <direct_front_name> node.

<global>
    <request>
        <direct_front_name>
            <frontnames/>
            <here/>
            <skip/>
            <store-code-in-url/>
        </direct_front_name>
    </request>
</global>

There was much rejoicing. Putting a front name here ensured links with said front name were generated without a prepended store code.

Then I noticed it didn’t work for about half the links on the site. It turns out the <direct_front_name> feature doesn’t work with URLs generated by store directives in CMS/Static-Block templates

{{store direct_url='always-gets-a-store-code'}}

A bug? A feature? A bug maintained as a feature to ensure backwards compatibility? Two systems developed by engineers who didn’t or couldn’t talk to one another?

In the end we decided on a quick search and replace through the CMS tables and hard-coded URLs.

Copyright © Alan Storm 1975 – 2017 All Rights Reserved

Originally Posted: 8th February 2012