9

By default the Magento URL for the review form is like:

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 this URL:

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

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

How can I achieve that?

7
  • you need to make a custom extension for this. Jun 1, 2015 at 14:08
  • @DeepKakkar And how should I do that?
    – JGeer
    Jun 1, 2015 at 14:47
  • what your mean by product url.... that format review/product/list/id/410/category/14/#review-form
    – Amit Bera
    Jun 6, 2015 at 15:02
  • @AmitBera What I mean is that I want to load this not as a anchor url on the same page. But I want to load the review form on a individual page
    – JGeer
    Jun 7, 2015 at 8:51
  • Can you put an example URL for current review URL and new new url
    – Amit Bera
    Jun 7, 2015 at 8:53

2 Answers 2

6
+50

In this case,it will better idea to create custom route like Mage_Cms module.

Where depends on request path using Custom route match internally set the request path

  • modules ->Mage_Review

  • controller ->ProductController.php

  • Action ->listAction.

Customer will see that like

http://www.example.com/laptop1-review-form

but internally it hit to

http://www.example.com/review/product/list/id/33661/

Here

`laptop1` is  `product url_path` value
 `33661` is `product id` 

 `-reviews-form` suffix for review url as you want
  1. create custom font router for this custom module

`<frontend>
    <routers>
        <productview> <!--  router identifire -->
            <use>standard</use>
            <args>
                <modules>
                    <module>Dev_Productreview</module>
                    <frontName>productreview</frontName>
                </modules>
            </args>
        </productview>
    </routers>
</frontend>`

Refernce

  1. Add an observer on controller_front_init_routers

<controller_front_init_routers>
        <observers> 
        <add_review_route>  <!-- observer identifier -->
            <class>Dev_Productreview_Controller_Router</class>
            <method>initControllerRouters</method>
        </add_review_route> 
        </observers>
    </controller_front_init_routers>

This observer add new routers 



public function initControllerRouters($observer){
        $front=$observer->getEvent()->getFront();
        $front->addRouter('productreview',$this);
        
    }

3.add router class

. Now you need define router class at Controller folder not controllers folders

Where using match () check the request path match with your pattern (producturl)-review-form. . check string review-form exits in this request path() reference

$requestPathInfo=trim($request->getPathInfo(),'/'); 
    if(strpos($requestPathInfo,'-review-form')==false):
            return  false;
        endif;

4.Get product url from request path and save it

If request path contain review-form then then save require an variable then remove review-form from this string.

$producturl=str_replace('-review-form','',$requestPathInfo)
  1. Check product exits in current store

Then using $producturl check this path for which product

$Rewrite=Mage::getModel('core/url_rewrite')
                    ->setStoreId(Mage::app()->getStore()->getId())
                    ->loadByRequestPath($identifier);
  1. Set internal request Module,controller,Action name

If product is exits then module,controller,action for this request. which will be hit

Mage_Review Module ProductController at listAction

$request->setModuleName('review') 
            ->setControllerName('product')
            ->setActionName('list')
        ->setParam('id', $productid);
  1. Finally now set request alias as producturl-review-form thus customer can only laptop1-review-form as review page.

Hope this will help you

you can get full module at Github

In this module i have make review like :

http://YOurmagentoInstanceurl/linen-blazer-585.html-review-form

whenerever product url is

http://YOurmagentoInstanceurl/linen-blazer-585.html
2
  • Many thanks! I placed the full module of Github on my store. But where can I find the reviews and where can I find the review form? What are the URL's
    – JGeer
    Jun 11, 2015 at 10:05
  • suppose linen-blazer-585.html is product then you can this product review page by suffix add -review-form end of product url ( linen-blazer-585.html-review-form)
    – Amit Bera
    Jun 11, 2015 at 10:24
0

In your review-form phtml file, call directly the review block.

$this->getLayout()
 ->createBlock("review/product_view_list")
 ->setTemplate("review/product/view/list.phtml")
 ->toHtml();

You can find all block name and block template in xml layout files (example here : http://doc-magento.com/nav.html?app/design/frontend/base/default/layout/review.xml.source.html)

7
  • Thanks! But how do I get it on its own page then?
    – JGeer
    Jun 9, 2015 at 12:59
  • you must create a local module to configure routing (magentocommerce.com/knowledge-base/entry/…)
    – Nolwennig
    Jun 9, 2015 at 13:59
  • and add in method_block, layout (code.tutsplus.com/tutorials/…) and finally your review-form.phtml with the call to default review block
    – Nolwennig
    Jun 9, 2015 at 14:10
  • Why ? have you any error message or unexpected behavior ?
    – Nolwennig
    Jun 10, 2015 at 9:38
  • No, I can get it done with the instructions. Can you give me an example code of the local module that should be created?
    – JGeer
    Jun 10, 2015 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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