Magento – Load review form on external page

extensionslayoutreviewroutingxml

By default the Magento URL for the review form is:

www.domain.com/(producturl)-reviews#review-form.

But in this page the review-form is a section in the reviews page.

I want to load the review-form in unique page with a URL something like:

www.domain.com/(producturl)-review-form.

This review-form will only be the form for this product.

How can I achieve that?

Best Answer

If this exact url structure is an requirement, you could solve this by implementing an own router.

the xml needed is something like

<config>
    <default>
    <web>
        <routers>
            <my_review>
                <area>frontend</area>
                <class>My_Review_Controller_Review_Router</class>
            </my_review>
        </routers>
    </web>
    </default>
</config>

this class needs to extend from Mage_Core_Controller_Varien_Router_Standard and overwrite the match method.

You can then parse the url, if it ends with -review-form you can extract the product part, and see if you have a product with this url-key or look in the rewrite table for it, not sure what is more stable. If it does not match, exit the function with a return. If it matches, I would suggest to an internal redirect to a route of your controller which is implemented as the others suggested.

The performance impact is nearly nothing, as you dont cause a database query for the initial -review-form test, and trough the internal redirect towards a normal controller you keep the additional complexity low.

Related Topic