Magento – get scope_id value from current store-view

core-config-datamagento-1magento-1.9store-view

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

Mage::app()->getStore()->getStoreId();

But this doesn't return the scope_id value.

Thanks!

Best Answer

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