简体   繁体   English

Magento地理定位/ FPC

[英]Magento Geolocalization/FPC

In Magento EE I need to redirect customers depending Origin country, browser lang and previous preference set in a cookie. 在Magento EE中,我需要根据原始国家/地区,浏览器lang和cookie中设置的先前首选项来重定向客户。

I have huge problems making it work with FPC. 我在使其与FPC一起使用时遇到很大的问题。

I tryed to observe the controller_action_predispatch event, but FPC somehow caches my redirect instruction and customer is not redirected. 我试图观察controller_action_predispatch事件,但是FPC某种程度上缓存了我的重定向指令,而客户没有被重定向。

I then tried another solution: extending the run() method in Mage_Core_Model_App in order to perform operations before FPC starts to work. 然后,我尝试了另一种解决方案:在Mage_Core_Model_App中扩展run()方法,以便在FPC开始工作之前执行操作。

Unfortunately, I don't know why, inside this method you can't access Mage::getModel() , Mage::helper() , Mage::getConfig() ecc 不幸的是,我不知道为什么,在此方法内您无法访问Mage::getModel()Mage::helper()Mage::getConfig() ecc

Can you help me please? 你能帮我吗?

Thank you 谢谢

I've recently been through exactly the same pain. 我最近经历了同样的痛苦。 You are on the right track; 您走在正确的轨道上;

controller_action_predispatch

Is the correct event to observe, and you can use this quite happily if you are redirecting to a category or product page with FPC enabled. 这是要观察的正确事件,如果您要重定向到启用了FPC的类别或产品页面,则可以很愉快地使用它。 The problem is the home page - which is a cms page. 问题是主页-这是一个cms页。 The cms page cache does not fire controller_action_predispatch. cms页面缓存不会触发controller_action_predispatch。 I got around this by adding this to my observer; 我通过将其添加到观察者中来解决此问题;

public function switchUser($event)
{

// CMS page bug, disable FPC to still use observer
    $action = $event->getEvent()->getControllerAction();
    if($action instanceof Mage_Cms_IndexController) {
         $cache = Mage::app()->getCacheInstance();
         $cache->banUse('full_page');
     }
// do the rest of your code here
}

The blocks within the cms page will still cache so the page is still nippy, though obviously not as fast as it would be with full FPC enabled. cms页面中的块仍将缓存,因此该页面仍然是糊状的,尽管显然不如启用完整FPC的速度快。 Its a sound trade off in my opinion. 我认为这是一个合理的权衡。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM