本文整理汇总了PHP中Varien_Event_Observer::getWebsite方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getWebsite方法的具体用法?PHP Varien_Event_Observer::getWebsite怎么用?PHP Varien_Event_Observer::getWebsite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getWebsite方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: adminSystemConfigSavedAtosSection
public function adminSystemConfigSavedAtosSection(Varien_Event_Observer $observer)
{
$model = Mage::getModel('salesrule/rule');
$data = Mage::app()->getRequest()->getPost();
$store = $observer->getStore();
$website = $observer->getWebsite();
if ($store) {
$scope = 'stores';
$scopeId = (int) Mage::getConfig()->getNode('stores/' . $store . '/system/store/id');
} elseif ($website) {
$scope = 'websites';
$scopeId = (int) Mage::getConfig()->getNode('websites/' . $website . '/system/website/id');
} else {
$scope = 'default';
$scopeId = 0;
}
$validateResult = $model->validateData(new Varien_Object($data));
if ($validateResult !== true) {
foreach ($validateResult as $errorMessage) {
Mage::getSingleton('core/session')->addError($errorMessage);
}
# $this->_redirect('*/*/edit', array('_current' => array('section', 'website', 'store')));
# return;
} else {
if (isset($data['rule'])) {
if (count($data['rule']['conditions']) > 1) {
Mage::getConfig()->saveConfig('atos/securecode/conditions', serialize(array('conditions' => $data['rule']['conditions'])), $scope, $scopeId);
} else {
Mage::getConfig()->deleteConfig('atos/securecode/conditions', $scope, $scopeId);
}
unset($data['rule']);
}
}
}
示例2: saveConfig
public function saveConfig(Varien_Event_Observer $observer)
{
// Defaults for "global" scope
$scope = 'default';
$scopeId = 0;
$websiteCode = $observer->getWebsite();
$storeCode = $observer->getStore();
if ($websiteCode) {
$scope = 'website';
$website = Mage::getModel('core/website')->load($websiteCode);
$scopeId = $website->getId();
}
if ($storeCode) {
$scope = 'store';
$store = Mage::getModel('core/store')->load($storeCode);
$scopeId = $store->getId();
}
$enableEmail = Mage::getStoreConfig('zendesk/frontend_features/contact_us', $storeCode);
$currentEmail = Mage::getStoreConfig('contacts/email/recipient_email', $storeCode);
$oldEmail = Mage::getStoreConfig('zendesk/hidden/contact_email_old', $storeCode);
$zendeskEmail = Mage::helper('zendesk')->getSupportEmail($storeCode);
if ($enableEmail) {
// If the email is already set, then do nothing
if ($currentEmail !== $zendeskEmail) {
// Ensure the email address value exists and is valid
if (Zend_Validate::is($zendeskEmail, 'EmailAddress')) {
Mage::getModel('core/config')->saveConfig('zendesk/hidden/contact_email_old', $currentEmail, $scope, $scopeId);
Mage::getModel('core/config')->saveConfig('contacts/email/recipient_email', $zendeskEmail, $scope, $scopeId);
}
}
} else {
// If the email hasn't been set, then we don't need to restore anything, otherwise overwrite the current
// email address with the saved one
if ($currentEmail === $zendeskEmail) {
// If the old email is the Zendesk email then we still need to disable it, so set it to the "general"
// contact email address
if ($oldEmail === $zendeskEmail) {
$oldEmail = Mage::getStoreConfig('trans_email/ident_general/email', $storeCode);
}
Mage::getModel('core/config')->saveConfig('contacts/email/recipient_email', $oldEmail, $scope, $scopeId);
}
}
// If the zendesk domain is not found in the web widget snippet (wrapped with quotes), generate it again
$zDomain = Mage::getStoreConfig('zendesk/general/domain', $storeCode);
$widgetSnippet = Mage::getStoreConfig('zendesk/frontend_features/web_widget_code_snippet', $storeCode);
// Case insensitive search with single and double quotes, still better performance than 1 regexp search
if ($zDomain && stripos($widgetSnippet, "'{$zDomain}'") === false && stripos($widgetSnippet, '"' . $zDomain . '"') === false) {
$webWidgetSnippet = <<<EOJS
<!-- Start of Zendesk Widget script -->
<script>/*<![CDATA[*/window.zEmbed||function(e,t){var n,o,d,i,s,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),i=r.contentWindow,s=i.document;try{o=s}catch(c){n=document.domain,r.src='javascript:var d=document.open();d.domain="'+n+'";void(0);',o=s}o.open()._l=function(){var o=this.createElement("script");n&&(this.domain=n),o.id="js-iframe-async",o.src=e,this.t=+new Date,this.zendeskHost=t,this.zEQueue=a,this.body.appendChild(o)},o.write('<body onload="document._l();">'),o.close()}("https://assets.zendesk.com/embeddable_framework/main.js","{$zDomain}");/*]]>*/</script>
<!-- End of Zendesk Widget script -->
EOJS;
Mage::getModel('core/config')->saveConfig('zendesk/frontend_features/web_widget_code_active', 1);
Mage::getModel('core/config')->saveConfig('zendesk/frontend_features/web_widget_code_snippet', $webWidgetSnippet);
} elseif (empty($zDomain)) {
Mage::getModel('core/config')->saveConfig('zendesk/frontend_features/web_widget_code_snippet', '');
}
}
示例3: createByWebsite
/**
* @param Varien_Event_Observer $observer
*/
public function createByWebsite(Varien_Event_Observer $observer)
{
/** @var $website Mage_Core_Model_Website */
$website = $observer->getWebsite();
if (!$website->isObjectNew()) {
return;
}
$service = $this->getFactory()->getServiceConfigPaymentMethodCreate();
$service->executeByWebsite($website);
}
示例4: saveConfig
public function saveConfig(Varien_Event_Observer $observer)
{
// Defaults for "global" scope
$scope = 'default';
$scopeId = 0;
$websiteCode = $observer->getWebsite();
$storeCode = $observer->getStore();
if ($websiteCode) {
$scope = 'website';
$website = Mage::getModel('core/website')->load($websiteCode);
$scopeId = $website->getId();
}
if ($storeCode) {
$scope = 'store';
$store = Mage::getModel('core/store')->load($storeCode);
$scopeId = $store->getId();
}
$enableEmail = Mage::getStoreConfig('zendesk/features/contact_us', $storeCode);
$currentEmail = Mage::getStoreConfig('contacts/email/recipient_email', $storeCode);
$oldEmail = Mage::getStoreConfig('zendesk/hidden/contact_email_old', $storeCode);
$zendeskEmail = Mage::helper('zendesk')->getSupportEmail($storeCode);
if ($enableEmail) {
// If the email is already set, then do nothing
if ($currentEmail !== $zendeskEmail) {
// Ensure the email address value exists and is valid
if (Zend_Validate::is($zendeskEmail, 'EmailAddress')) {
Mage::getModel('core/config')->saveConfig('zendesk/hidden/contact_email_old', $currentEmail, $scope, $scopeId);
Mage::getModel('core/config')->saveConfig('contacts/email/recipient_email', $zendeskEmail, $scope, $scopeId);
}
}
} else {
// If the email hasn't been set, then we don't need to restore anything, otherwise overwrite the current
// email address with the saved one
if ($currentEmail === $zendeskEmail) {
// If the old email is the Zendesk email then we still need to disable it, so set it to the "general"
// contact email address
if ($oldEmail === $zendeskEmail) {
$oldEmail = Mage::getStoreConfig('trans_email/ident_general/email', $storeCode);
}
Mage::getModel('core/config')->saveConfig('contacts/email/recipient_email', $oldEmail, $scope, $scopeId);
}
}
}
示例5: getDefaultStoreId
/**
* Try to get default store id from observer
*
* @param Varien_Event_Observer $observer
* @return mixed
* @throws Mage_Core_Exception
*/
protected function getDefaultStoreId(Varien_Event_Observer $observer)
{
$website = $observer->getWebsite();
if ($website) {
$website = Mage::app()->getWebsite($website)->getDefaultGroup()->getDefaultStoreId();
}
return $website;
}