简体   繁体   English

Magento - 将点击评论页面的客户重定向到产品页面

[英]Magento - Redirect customer who hits review page to product page

有没有办法将访问产品评论页面(http://mydomain.com/review/product/list/id/139/category/79/)的客户重定向到实际的产品页面?

Assuming that seo friendly url is enable, then you could create a custom module that extend review/product and rewrite listAction method 假设启用了seo friendly url,那么您可以创建一个自定义模块来扩展review / product并重写listAction方法

In /app/etc/modules/MageIgniter_ReviewRedirect.xml 在/app/etc/modules/MageIgniter_ReviewRedirect.xml中

<?xml version="1.0"?>
<config>
  <modules>
    <MageIgniter_ReviewRedirect>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </MageIgniter_ReviewRedirect>
  </modules>
</config>

In /app/code/local/MageIgniter/ReviewRedirect/controller/ReviewController.php 在/app/code/local/MageIgniter/ReviewRedirect/controller/ReviewController.php中

include_once 'Mage/Review/controllers/ProductController.php';
class MageIgniter_ReviewRedirect_ReviewController extends Mage_Review_ProductController
{
    public function listAction(){
       if ($product = $this->_initProduct()) {
            $this->_redirect($product->getUrl());
       }

    }

in In /app/code/local/MageIgniter/ReviewRedirect/etc/config.xml 在/app/code/local/MageIgniter/ReviewRedirect/etc/config.xml中

<?xml version="1.0"?>
<config>
  <modules>
    <MageIgniter_ReviewRedirect>
      <version>0.1.0</version>
    </MageIgniter_ReviewRedirect>
  </modules>
  <frontend>
    <routers>
      <reviewredirect>
        <use>standard</use>
          <args>
            <modules>
                <MageIgniter_ReviewRedirect before="Mage_Review">MageIgniter_ReviewRedirect<MageIgniter_ReviewRedirect>
            </modules>
            <frontName>review</frontName>
          </args>
      </reviewredirect>
    </routers>
  </frontend>
  <global>
    <helpers>
      <reviewredirect>
        <class>MageIgniter_ReviewRedirect_Helper</class>
      </reviewredirect>
    </helpers>
  </global>
</config> 

In /app/code/local/MageIgniter/ReviewRedirect/Helper/Data.php 在/app/code/local/MageIgniter/ReviewRedirect/Helper/Data.php中

<?php
class MageIgniter_ReviewRedirect_Helper_Data extends Mage_Core_Helper_Abstract
{
}

You could place a redirect on the method listAction in the ProductController. 您可以在ProductController中的方法listAction上放置重定向。 (app/code/core/mage/Review/controllers/ProductController.php) (应用程序/代码/核心/法师/评论/控制器/ ProductController.php)

Edit: Best practice is to create your own module to overwrite this controller, 编辑:最佳做法是创建自己的模块来覆盖此控制器,

There is an otherwise defunct feature from old Magento which only requires a module config: 旧Magento还有一个其他功能,它只需要一个模块配置:

<config>
    <global>
        <rewrite>
            <yourmodulename>
                <from><![CDATA[#^/review/product/list#]]></from>
                <to><![CDATA[/catalog/product/view]]></to>
            </yourmodulename>
        </rewrite>
    </global>
</config>

Underneath it is just using preg_replace on the requested path so you should have no trouble understanding the PCRE patterns. 在它下面只是在请求的路径上使用preg_replace ,所以你应该没有理解PCRE模式。 With a bit of imagination you could even merge the above into app/etc/local/xml if you didn't want to create a whole module just for this. 如果你不想为此创建一个完整的模块,你甚至可以将上面的内容合并到app/etc/local/xml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Magento从产品查看页面上删除客户评论区 - Magento remove customer review block from product view page 将客户重定向到客户登录网站的产品页面 Magento 2 - Redirect customer to product page from where customer logged in to website Magento 2 将未登录的用户添加到愿望清单后,Magento重定向到产品页面 - Magento redirect to product page after add to wishlist for user who is not logged in Magento产品评论提交退货页面 - Magento product review submition return page Magento:将内容移至产品页面上的“评论”选项卡 - Magento : Moving content to the review tab on the product page 只有当客户登录时,我才想重定向到 Magento 页面(产品/类别等)。否则它应该重定向到客户登录页面 - I want to redirect to Magento Pages (Product/Categories etc.) only if Customer is Logged in. Otherwise it Should Redirect to Customer Login page 将产品页面重定向到带有Magento中图像的自定义页面 - Redirect Product page to custom page with image in Magento 在magento上,当客户访问某种产品时,如何重定向页面? - on magento, how can I redirect the page when the customer visits a certain product? Magento审查已登录客户使用一种产品的情况 - Magento review for logged in customer on one product Magento-在同一页面上显示单个产品的所有评论 - Magento - show all review of a single product on the same page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM