我如何用seo Url程序化地将图像切换到商店



如何在不创建单独文件夹的情况下用seo Url程序化地将图像切换到存储?。

我的自定义模块中有一个storeController。

它工作不完美。当前商店cookie值没有更改,因为当我转到主页时,它会自动转到默认商店。

这就是我想要的(我真的需要一个商店切换效果)。

www.site.com/module/store/id/

我的店铺控制器

class Namespace_Module_StoreController extends Mage_Core_Controller_Front_Action
{
 public function indexAction()
 {   
    // site.com/module/store/12-store1
    $id = explode('-',$this->getRequest()->getParam('id'));
    $id = $id[0];
    $store = Mage::getModel( 'core/store' )->load($id); 
    $this->_title($this->__('Module'))->_title($store->getName());
    $rootCategoryId = $store->getRootCategoryId();
    Mage::app()->setCurrentStore($store->getStoreId()); 
    $this->loadLayout();   
    $this->renderLayout();
  }
}

此时,控制器的深度太深,无法切换存储。存储运行代码只能在应用程序以引导级别(是,index.php)加载时设置,而不能在之后的任何时间(其中包括控制器调度)设置。

去别的地方碰碰运气。。一个好的解决方案是在启动之前使用.htaccess设置MAGE_RUN_CODE(到您想要的商店视图)和MAGE_RUN_TYPE(到商店/网站)环境变量。

最新更新