How i can get the scope_id value from core_config_data table of the current store-view?. I've tried using:


But this doesn't return the scope_id value.


  • Why do you need scope_id? – oleksii.svarychevskyi Mar 7 '14 at 14:35
  • because i need to get the config paths from an specific scope_id (store-view), when data is saved after selecting a store-view – Guille Mar 7 '14 at 14:39
  • 2
    @Guille is this is the front end or the admin? Cause in the admin section Mage::app()->getStore()->getStoreId(); will always be the admin store id which is 0 – David Manners May 22 '14 at 16:01

core_config_data table contain two important fields scope and scope_id.

There are three scope types

  • default
  • websites
  • stores

If scope is set to default then scope_id is always 0.

If scope is set to websites then scope_id is website_id.

If scope is set to stores then scope_id is store_id(store view).

Imagine that we need to get some config value. How Magento will get the it for current store view?

Search value by priority:

  • scope == stores and scope_id == store_id(store view)

  • scope == websites and scope_id == website_id (to which belongs current store view)

  • scope == default

  • default section of config.xml

| improve this answer | |
  • Thanks. However when i tried to retrieve the scope_id value with Mage::app()->getStore()->getStoreId(); i always receive "0" on frontend, but when i check the table it says 2 or 3 depending on the store-view i selected... – Guille Mar 7 '14 at 15:04
  • Do you switch between store views on frontend? – oleksii.svarychevskyi Mar 7 '14 at 15:07
  • no, i need to get the current scope_id value of the selected store-view when the user press Save Config. button – Guille Mar 7 '14 at 15:08
  • scope_id is different for different config values and is not unique for the store view. – oleksii.svarychevskyi Mar 7 '14 at 15:10
  • i think scope_id value is unique because when i check the sql table core_config_data directly, i can see this value changes depending on the store-view i select, eg: English = 1, German = 2 etc.... – Guille Mar 7 '14 at 15:11

You can get current scope_id value after Save Config with this:

$code = Mage::getSingleton('adminhtml/config_data')->getStore();

$store_id = Mage::getModel('core/store')->load($code)->getId();

| 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.