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?
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
`<frontend>
<routers>
<productview> <!-- router identifire -->
<use>standard</use>
<args>
<modules>
<module>Dev_Productreview</module>
<frontName>productreview</frontName>
</modules>
</args>
</productview>
</routers>
</frontend>`
Refernce
<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);
}
. 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;
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)
Then using $producturl
check this path for which product
$Rewrite=Mage::getModel('core/url_rewrite')
->setStoreId(Mage::app()->getStore()->getId())
->loadByRequestPath($identifier);
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);
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With