If you wanted this as a feature you can
write a module, and observe the save product event and loop through all the stores and either:
- condition based looking for "english" if they are named like that
- hardcode the id's
- provide a configuration option in the admin to select the english stores.
- add an attribute to the store object
Another way to do it as a one off:
<?php
require '../app/Mage.php';
$englishStore = 1; // English Store (the one you want to copy from)
$attribute = "short_description"; // Attribute to copy
foreach (Mage::app()->getWebsites() as $website) {
foreach ($website->getGroups() as $group) {
$stores = $group->getStores();
foreach ($stores as $store) {
//store object
//print_r($store->getData());
// if english found in name or change this so it's hardcoded store id's
if (strstr($store->getData('name'),"english")) {
$StoreToUpdateCollection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('store_id', $store->getData('store_id'));
foreach ($StoreToUpdateCollection as $product) {
// get the description from the base English store
$englishProduct = Mage::getModel('catalog/product')->setStoreId($englishStore)->loadByAttribute('sku', $product->getData('sku'));
$newValue = $englishProduct->getData($attribute);
// update the attributes for the current store for the product ID
Mage::getSingleton('catalog/product_action')->updateAttributes(
array($product->getData('id')),
array($attribute => $newValue),
$store->getData('store_id')
);
}
}
}
}
}
I have not tested the updating part, would suggest trying this on a dev version.
We managed to make the store switcher and login a bit more stable with new configuration.
Add Store Code to Urls
The biggest change was setting Add Store Code to Urls
to "Yes".
Stores =>
Configuration in Settings section =>
select Default Config
=>
Web in GENERAL section =>
Url Options =>
change the Add Store Code to Urls
to "Yes"
Remove Cookie Domain
Then, we removed Cookie Domain
value from Store2 and Store3 from the Configuration page.
Stores =>
Configuration in Settings section =>
select Store2 or Store3 =>
Web in GENERAL section =>
Default Cookie Settings =>
remove the value from Cookie Domain
and leave it blank
Remove custom codes from .htaccess
and index.php
Then, we removed custom code lines form .htaccess
and index.php
.
With the new configuration, the customization on these files were no longer needed. This is great, cleaner code.
After these changes, the store switcher, shared shopping cart, and user login became much more stable. Make sure you clear the cache after you make these changes.
Magento2 core upgrade and its effect on .htaccess
and index.php
Before making config and file changes, we upgraded the Magento2 core from 2.1.0 to 2.1.3 using composer
. (Reference: Update Magento 2.1.2 for 2.1.3 )
We are not sure this will be a required part for this multi store configuration, but we performed it hoping the site will be more stable with latest updates from 2.1.3
We had 3 files modified which which were part of core and module files (these files are ignored by our Git version control):
- .htaccess
- index.php
- dev/tools/grunt/configs/themes.js (Grunt config file to compile our custom theme css)
When we upgraded Magento2, these files are reset to initial state of 2.1.3. We did NOT have to manually clean up our .htaccess
and index.php
files. The file contents were automatically reset by the upgrade. This was a positive side effect.
But there was also a bad side effect. Our custom code in the Grunt config file was reset and erased by the core upgrade. We had to manually restore our custom code lines on this file.
I recommend to take file and DB backups before doing this core upgrade and config/file changes.
Minifying Javascript might help
Minifying JS made the entire site more stable on our site.
Stores =>
Configuration in Settings section =>
select Default Config
=>
Developer in ADVANCED section =>
JavaScript Settings =>
set Merge JavaScript Files
to "Yes" =>
set Enable JavaScript Bundling
to "Yes" =>
set Minify JavaScript Files
to "Yes" =>
then, clear cache
Best Answer
On Magento 2.1.5 :
Stores > Configuration > Web > Url Options, with selected Store view : "Default Config"
switch option "Add Store Code to Urls" to "Yes" :
you don't need to change base urls