How to filter the store views so that only information for mobile stores will be saved?
-
08-01-2021 - |
Вопрос
How to add a filter to the following piece of code
foreach($this->getStores() as $_store {
$storeName = $this->__($this->htmlEscape($_store->getName()));
$storeId = $_store->getId();
$storeCode = $_store->getCode();
}
in a way that magento will only get that info for mobile store views? The code for all mobile store views is $mageRunCode .= '_mobile'
Решение 2
Got is as follows:
foreach (Mage::app()->getWebsites() as $website) {
foreach ($website->getGroups() as $group) {
$stores = $group->getStores();
foreach ($stores as $_store) {
$storeCode = $_store->getCode();
$storeId = $_store->getId();
$storeName = $this->__($this->htmlEscape($_store->getName()));
if (strpos($storeCode, '_mobile') !== false) {
if ($_store->getIsActive()) {
}
}
}
}
}
Другие советы
You can try to adjust the store below way:
foreach($this->getStores() as $_store {
$storeId = $_store->getId();
Mage::app()->setCurrentStore($storeId);
// after that get information of that store.
}
Не связан с magento.stackexchange