每个商店都有自己的媒体文件夹? [英] Every store have their own media folder?

查看:52
本文介绍了每个商店都有自己的媒体文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在magento中有一个需要覆盖的代码,可以在/app/code/core/Mage/Core/Model/Config/Options.php中找到该代码.

i have a code in magento that i need to overwrite, code can be found in /app/code/core/Mage/Core/Model/Config/Options.php.

代码如下:

protected function _construct()
    {



        $appRoot= Mage::getRoot();
        $root   = dirname($appRoot);

        $this->_data['app_dir']     = $appRoot;
        $this->_data['base_dir']    = $root;
        $this->_data['code_dir']    = $appRoot.DS.'code';
        $this->_data['design_dir']  = $appRoot.DS.'design';
        $this->_data['etc_dir']     = $appRoot.DS.'etc';
        $this->_data['lib_dir']     = $root.DS.'lib';
        $this->_data['locale_dir']  = $appRoot.DS.'locale';
        $this->_data['media_dir']   = $root.DS.'default_media';
        $this->_data['skin_dir']    = $root.DS.'skin';
        $this->_data['var_dir']     = $this->getVarDir();
        $this->_data['tmp_dir']     = $this->_data['var_dir'].DS.'tmp';
        $this->_data['cache_dir']   = $this->_data['var_dir'].DS.'cache';
        $this->_data['log_dir']     = $this->_data['var_dir'].DS.'log';
        $this->_data['session_dir'] = $this->_data['var_dir'].DS.'session';
        $this->_data['upload_dir']  = $this->_data['media_dir'].DS.'upload';
        $this->_data['export_dir']  = $this->_data['var_dir'].DS.'export';
       }

我需要更改默认媒体,每个商店都有自己的媒体文件夹.所以我做了功能...

I need to change default media, that every store have her own media folder. So i made function...

public function getMediaFromStore(){
    $fullMediaUrl=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
    $baseUrl = Mage::getBaseUrl();
    echo substr(Mage::getBaseUrl($fullMediaUrl, strlen($baseUrl));
}

然后,而不是

$this->_data['media_dir']   = $root.DS.'default_media';

我放

$this->_data['media_dir']   = $root.DS.$this->getMediaFromStore();

我遇到了严重的错误,就像这样...

and i got freaking error, that goes like this...

致命错误:在非对象中调用成员函数getOptions() /home/cofamedia/www/magento/app/Mage.php,第328行

Fatal error: Call to a member function getOptions() on a non-object in /home/cofamedia/www/magento/app/Mage.php on line 328

我被困住了,你们中的任何一个都对如何解决这个错误有一些解释.并为每个商店的Magento中的每个媒体文件夹执行操作.谢谢你.

And i m stucked, does any of you have some explanation how to go over this error. And do for every store every media folder in Magento. Thank you.

推荐答案

这是一个非常棘手的更改. 如果您需要在核心类中实现此更改,最好将文件复制到 app/code/local/Mage/Core/Model/Config/Options. php ,然后在此处进行更改,以防止在升级过程中被覆盖.

This is a very sticky change to make. If you need to implement this change in the core class, it would be better to copy the file to app/code/local/Mage/Core/Model/Config/Options.php and make your change there to protect against overwrite in an upgrade.

但是,我认为最好在CMS所见即所得(WYSIWYG)建模中进行更改以添加商店路径.可能会改变行为和价值观,但是您可以从例如

However, I think that it would be better to implement a change in the CMS WYSIWYG modeling to add store path in. I'm not sure of all of the places where you will need to look for & potentially alter behavior and values, but you can start for example in Mage_Cms_Helper_Wysiwyg_Images::getStorageRoot().

请注意,用于写入存储和从中读取的路径(文件系统路径)不同于前端中所需的路径(URL路径).您当前的示例正在尝试将后者用于前者,除非您对文件操作和URL包装器有一些疯狂的想法,否则它将无法正常工作.

Note that the path for writing to and reading from storage (the filesystem path) is different from what will be needed in the frontend (the URL path). Your current example is trying to use the latter for the former, which will not work unless you have something hella crazy going on with file operations and URL wrappers.

这篇关于每个商店都有自己的媒体文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆