0

I have successfully managed to change the destination of CMS wysiwyg folder thanks to Marius, here but that is relative to media dir that is defauled to ./media.

Now I have made module to change the core fn getMediaDir but somehow I think it is somewhere else defined,, but I can't find where?

This is what I defined for module:

http://i.stack.imgur.com/Je7vY.png

<?xml version="1.0"?>
<config>
  <modules>
    <Mk_Hub>
      <version>0.1.0</version>
    </Mk_Hub>
  </modules>
  <global>
    <helpers>
      <hub>
        <class>Mk_Hub_Helper</class>
      </hub>
    </helpers>
    <models>
      <hub>
        <class>Mk_Hub_Model</class>
        <resourceModel>hub_mysql4</resourceModel>
      </hub>
            <core>
                <rewrite>
                    <config_options>Mk_Hub_Model_Core_Config_Options</config_options>
                </rewrite>
            </core>
    </models>
  </global>
</config> 

and :

<?php
class Mk_Hub_Model_Core_Config_Options extends Mage_Core_Model_Config_Options
{

    public function getMediaDir()
    {
        return $this->getBaseDir().DS.'media' . '/' . 'subdir1');
        // return $this->_data['media_dir'];
    }



}
  • ...why would you do this? – Ryre Aug 13 '13 at 15:33
1

I have never done this myself (the need has never occured)

Have a look at app/etc/config.xml, and you will find:

            <filesystem>
                <base>{{root_dir}}</base>
                <app>{{root_dir}}/app</app>
                <code>{{app_dir}}/code</code>
                <design>{{app_dir}}/design</design>
                <locale>{{app_dir}}/locale</locale>
                <etc>{{app_dir}}/etc</etc>
                <media>{{root_dir}}/media</media>
                <upload>{{root_dir}}/media/upload</upload>
                <skin>{{root_dir}}/skin</skin>
                <var>{{var_dir}}</var>
                <cache>{{var_dir}}/cache</cache>
                <session>{{var_dir}}/session</session>
                <tmp>{{var_dir}}/tmp</tmp>
                <pear>{{var_dir}}/pear</pear>
                <export>{{var_dir}}/export</export>
            </filesystem>

I am sure you can just change the default media path here by placing the directives in your app/etc/local.xml

|improve this answer|||||
  • HI @proxiblue, I tried that but that didn't worked.. I think that is used during setup for magento.. (the default values) right? – Kresimir Pendic Aug 13 '13 at 7:41
  • Pity, was hoping this would be a quick fix. Maybe someone can shed some light what these are exactly for, and how they can be used.... – ProxiBlue Aug 13 '13 at 9:15
1

I didn't go down the rabbit hole all the way, but I did find an easy way and it's in the options in admin backend ( System -> Configuration -> General -> Web ) unsecure and secure. You can alter the Base media URL or any other if you need to.

Or you can do it programmatically like this:

Mage::getConfig()->saveConfig( 'web/unsecure/base_media_url', '{{unsecure_base_url}}media/subdir1/' );
|improve this answer|||||
  • If you don't want to persist it (calling saveConfig will store to db) you can set it just for this session by calling setConfig instead) – philwinkle Aug 13 '13 at 15:08
0

You cannot rewrite the Mage_Core_Model_Config_Options class using XML rewrite because at the time the class Mage_Core_Model_Config_Options is initialised, Magento hasn't loaded the XML files. Look at the __construct function in the Mage_Core_Model_Config:

public function __construct($sourceData=null)
{
    $this->setCacheId('config_global');
    $this->_options         = new Mage_Core_Model_Config_Options($sourceData);
    $this->_prototype       = new Mage_Core_Model_Config_Base();
    $this->_cacheChecksum   = null;
    parent::__construct($sourceData);
}

Magento does not use the Mage::getModel(...), it calls new Mage_Core_Model_Config_Options directly.

The only way to overwrite this class is to create the same file structure under local, so it will be local/Mage/Core/Model/Config/Options.php. But it is not recommended. :)

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.