Hot answers tagged

16

Usually, you're not supposed to do this. Mage::getStoreConfig() will automatically return the store value, the website value, the global value, or the default value depending on the configuration of the field. However, if you really need to disregard the store value and get the website value, you can do it this way: Mage::app()->getWebsite()->...


12

Load is pretty expensive memory wise. You can use this for a faster update: Mage::getSingleton('catalog/product_action')->updateAttributes( array($productId), array('name' => $storeSpecificName), $storeId );


11

In, let's say, a Model for options in a dropdown, you could retrieve the active level using the following piece of code: if (strlen($code = Mage::getSingleton('adminhtml/config_data')->getStore())) // store level { $store_id = Mage::getModel('core/store')->load($code)->getId(); } elseif (strlen($code = Mage::getSingleton('adminhtml/config_data')...


8

This is a rare case, as settings are inherited to store level and usually getStoreConfig() takes the website settings into account. You can use Mage_Core_Model_Website::getConfig() - but be a aware that there is a slight difference to Mage_Core_Model_Store::getConfig() where also some processing is being done (for example substitution of {{...}}) - this ...


7

It's still a little unclear where, exactly, you're trying to grab this information in the admin. I'll assume it's while processing a request for the the System -> Configuration section. Hopefully this will send you in the right direction Like all form fields in Magento, you can grab the values of the fields from the request object. Doing something ...


6

This can be derived using the specific website code if known. $value = Mage::getConfig()->getNode('websites/[website_code]/section/group/field'); var_dump($value[0]);


6

Try like this: $websiteCode = Mage::app()->getRequest()->getParam('website'); if ($websiteCode) { $website = Mage::getModel('core/website')->load($websiteCode); $websiteId = $website->getId(); //do your magic with $websiteId } else { //it means you didn't select a website - either you selected a store view or default. }


6

Found it! Thanks to https://magento.stackexchange.com/a/90342/4090 $_product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId); $_product->setName($storeSpecificName); $_product->getResource()->saveAttribute($_product, 'name');


6

customer and customer_address Does not support Scope Attribute [Globle] catalog_category and catalog_product Does support Scope Attribute [Default, Website and Store] So the question is Sales tables does support Scope Attribute ? Because sales tables are stored as Flat table in Magento Sales DOES NOT support Scope Attributes. Confirmation 1 : Check ...


5

Pretty sure the system merges the configuration with no explicit order. In Magento/Framework/App/Utility/Files there's the following methods that gets all the di.xml from the module and merge them, according to the code the etc/di.xml is always first in the merge process: public function getDiConfigs($asDataSet = false) { $primaryConfigs = Glob::glob(...


5

Cron runs under console and system (server) doesn't know which store you are requested like on frontend. I do not think you need to care about scope in crontab. System runs cron jobs in crontab area and if you need to change something for the store you need to create new cron job, load this store and change it. Actually you can simply check this.. ...


4

Unfortunately there is no standard way to add scopes to admin pages, aside from the system configuration pages. If you only need it within the system configuration, the previous answers will help you. If not, this is how it is done in other core admin pages: Product management On the product grid as well as on the product edit page, store is simply a URL ...


4

To hide products on different stores, normally the Visibility is used which works on store level. I don't think it is a good idea to change the status scope to storeview, because indexing and other things are working with this value.


4

Let's say that $product is the instance of your product loaded in a specific store. You can check this $basePrice = $product->getAttributeDefaultValue('price'); if ($basePrice === false) { //Use default values is checked } else { //$basePrice is the price in the default values. } Unfortunately this works only if you call load on the product ...


4

The helper will only live during the execution, so #2 is true, it will not persist after the request. #3, sure you can save any data you want from the Helper into core/session, customer/session, checkout/session etc. #4, #5, #6 should return the same result no matter what. Calling the helper from a Model, Controller, even a template file will return the ...


4

Everything you wrote is accurate. To clarify the singleton behavior: both, Mage::helper() and Mage::getSingleton() look up an entry in the Magento registry (which is a global data storage per request) in the form _helper/module/class or _singleton/module/class and if it does not exist, instantiate the helper or singleton and store it in the registry.


4

In EAV models like the product, addFieldToFilter is just there for compatibility with the collection interface, it calls addAttributeToFilter which has an additional third parameter $joinType that defaults to "inner". public function addAttributeToFilter($attribute, $condition = null, $joinType = 'inner') So instead of addFieldToFilter($conditions), you ...


4

Whenever we have created two di.xml file for different area like, one di.xml file in etc base folder and one di.xml file are call inside {area}/di.xml file. Final outcomes are come from base di.xml file not from area di.xml file. Below result are outcomes of override files, This code for override topmenu block, app/code/Package/Module/registration....


4

The admin link is generate by this method \Magento\Catalog\Ui\Component\Listing\Columns\ProductActions::prepareDataSource() As you can see there is already a line that checks for a store id $storeId = $this->context->getFilterParam('store_id');. You can write an around plugin on this method. You will basically keep the same code but replace the ...


4

Inject the following dependency into your constructor /** * @var \Magento\Framework\App\Cache\TypeListInterface */ protected $cacheTypeList; /** * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList */ public function __construct( \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList ) { $this->cacheTypeList = $...


4

As per my understanding you can only create custom attribute for below entity types: Customer (Scope: Global) customer_address (Scope: Global) catalog_category (Scope: Default, Website and Store) catalog_product (Scope: Default, Website and Store) as when you have a look on eav_entity_type table's column additional_attribute_table and ...


3

You can set Copyright Field for each store view,


3

The <admin> tags allows you to define routes for the backend, the ACL for each module admin section and the theme for the admin. There are also some fieldsets defined in the Mage_Catalog module under this tag but the main things where you can use this tag are the 3 listed above. [EDIT] And you are right about the <adminhtml> tag. It's the ...


3

Default attribute set contains all of the system Attributes that are required for each Product The orange circles mark the System Attributes. Recall that every set must contain all of the System Attributes because each Product must have all of the System Attributes applied to it. You cannot delete a Group that has System Attributes in it. Update If you ...


3

The problem comes from here: Mage_Adminhtml_Block_System_Config_Form::initFields() [For Magento 1.7.0.0] Around line 295 there is this piece of code: if (isset($this->_configData[$path])) { $data = $this->_configData[$path]; $inherit = false; } else { $data = $this->_configRoot->descend($path); $inherit = true; } This ...


3

Attribute are defined in eav_attribute table. On Magento 1.4 those has these ID: short Description -> 506 Description -> 97 Name -> 96 Where data are stored: Values for NAME attribute are stored in catalog_product_entity_varchar table. Values for DESCRIPTION attribute are stored in catalog_product_entity_text table. How it works Magento creates a new ...


3

I have a solution, whether it is a good one I am not sure about but it does work. Disadvantages is that you have to have the Magento/blank theme installed and uses xpath so if Magento change their layout declaration it might break, both quite unlikely scenarios. Here is my final solution: class AccountLinks implements \Magento\Framework\Option\...


3

This is normal behavior. Store id 0 means "default values". When retrieving a value for an attribute, Magento does something like this. Do I have a value for the current store view id.? Yes: I use that. No: Do I have a value for the store view id 0? Yes: I use that No: Use null. So if you later add other store views and add values for those ...


2

I might be wrong, but as far as I remember, the configuration scope is always bound to stores. If you set a value on a website level, it will be available on any store of that website unless you set a different value on the store level. Say you have website A and store A1 and A2 are stores for that website. Assume that A has the value 5 for a given property ...


2

Solved by getting the current scope value with this: $scope = Mage::getSingleton('adminhtml/config_data')->getScope();


Only top voted, non community-wiki answers of a minimum length are eligible