Skip to content

Commit a0970ba

Browse files
authored
Merge pull request #128 from zendesk/samgavinio/MI-1571-fix-error-store-id
[MI-1571] Fix an incorrect assumption that a core_store_group with ID 1 always exists.
2 parents b42fea7 + ba507e3 commit a0970ba

File tree

1 file changed

+17
-16
lines changed
  • src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Config/Buttons

1 file changed

+17
-16
lines changed

src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Config/Buttons/Signup.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@ public function getPostUrl()
5151

5252
public function getPostInfo()
5353
{
54-
$stores = Mage::app()->getWebsites();
54+
$websiteCode = Mage::app()->getRequest()->getParam('website');
55+
if ($websiteCode) {
56+
$website = Mage::getModel('core/website')->load($websiteCode);
57+
} else {
58+
$website = Mage::getModel('core/website')->getCollection()
59+
->addFieldToFilter('is_default', 1)
60+
->getFirstItem();
61+
}
62+
63+
$storeCode = Mage::app()->getRequest()->getParam('store');
64+
if ($storeCode) {
65+
$store = Mage::getModel('core/store')->load($storeCode);
66+
} else {
67+
$store = $website->getDefaultStore();
68+
}
5569

5670
$info = array(
5771
'magento_domain' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB),
@@ -61,23 +75,10 @@ public function getPostInfo()
6175
'magento_callback' => Mage::helper('adminhtml')->getUrl('adminhtml/zendesk/redirect', array('type' => 'settings', 'id' => 'zendesk')),
6276
'magento_locale' => Mage::getStoreConfig('general/locale/code'),
6377
'magento_timezone' => Mage::getStoreConfig('general/locale/timezone'),
64-
'magento_api_url' => Mage::getUrl('zendesk/api', array('_store' => $stores[1]->getDefaultStore()->getCode()))
78+
'magento_api_url' => Mage::getUrl('zendesk/api', array('_store' => $store->getCode())),
79+
'magento_store_name' => $website->getName(),
6580
);
6681

67-
$storeName = Mage::getStoreConfig('general/store_information/name');
68-
69-
if(!$storeName) {
70-
$websites = Mage::getModel('core/website')->getCollection();
71-
foreach($websites as $website) {
72-
// Skip admin website
73-
if($website->getName() == 'Admin' || $website->getName() == 'Main Website') continue;
74-
75-
$storeName = $website->getName();
76-
}
77-
}
78-
79-
$info['magento_store_name'] = (string)$storeName;
80-
8182
return $info;
8283
}
8384
}

0 commit comments

Comments
 (0)