本文整理匯總了PHP中Varien_Event_Observer::getStore方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Event_Observer::getStore方法的具體用法?PHP Varien_Event_Observer::getStore怎麽用?PHP Varien_Event_Observer::getStore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getStore方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: addNew
/**
* Track the adding of a new store
*
* @param Varien_Event_Observer $event
*/
public function addNew(Varien_Event_Observer $event)
{
/** @var Mage_Core_Model_Store $store */
$store = $event->getStore();
$event = Mage::getModel('coscale_monitor/event');
$event->addEvent($event::TYPE_STORE_ADD, 'Store added', 'A new store was added', array('id' => $store->getId(), 'name' => $store->getName(), 'code' => $store->getCode(), 'website' => $store->getWebsiteId()), Mage::getSingleton('admin/session')->getUser()->getUsername());
}
示例3: validateConfig
/**
* Show notice if translation hints and inline tranlations are both enabled
*
* @param Varien_Event_Observer $observer
*/
public function validateConfig(Varien_Event_Observer $observer)
{
$storeId = $observer->getStore();
if (Mage::getStoreConfigFlag('dev/translate_inline/active', $storeId) && Mage::getStoreConfigFlag(SSE_TranslationHints_Model_Translate::XML_HINTS_ENABLED, $storeId)) {
$this->_session->addNotice($this->_helper->__('Translation hints do not work if inline translation is active.'));
}
}
示例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/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', '');
}
}
示例5: calculateAdjustment
public function calculateAdjustment(Varien_Event_Observer $observer)
{
$store = $observer->getStore();
$request = $observer->getRequest();
$allItems = $observer->getAllItems();
$adjustments = $observer->getAdjustments();
if (!$request->getFreeShipping()) {
$itemAdjustments = $adjustments->getItems();
$defaultAdjustment = Mage::helper('Lokey_PerItemShipping')->getDefaultAdjustment($store);
foreach ($allItems as $item) {
// Skip child items in main loop
if ($item->getParentItem()) {
continue;
}
$qty = (double) ($item->getFreeShipping() === true ? 0 : $item->getQty() - $item->getFreeShipping());
// Skip free shipping items
if ($qty <= 0.0) {
continue;
}
$product = Mage::getModel('catalog/product')->setStoreId($store->getId())->load($item->getProductId());
$adjustment = Mage::helper('Lokey_PerItemShipping')->getAdjustmentAmount($product, $defaultAdjustment);
// Skip virtual products
if ($product->getTypeInstance()->isVirtual()) {
continue;
}
if ($item->getHasChildren()) {
foreach ($item->getChildren() as $childItem) {
$childQty = (double) ($childItem->getFreeShipping() === true ? 0 : $childItem->getQty() - $childItem->getFreeShipping());
// Skip free shipping items
if ($childQty <= 0.0) {
continue;
}
$childProduct = Mage::getModel('catalog/product')->setStoreId($store->getId())->load($childItem->getProductId());
$childAdjustment = Mage::helper('Lokey_PerItemShipping')->getAdjustmentAmount($childProduct, $defaultAdjustment);
// Skip virtual products
if ($childProduct->getTypeInstance()->isVirtual()) {
continue;
}
if (Mage::helper('Lokey_PerItemShipping')->getUseQty($childProduct)) {
$adjustment += $childAdjustment * $childQty;
} else {
$adjustment += $childAdjustment;
}
}
}
if (!isset($itemAdjustments[$item->getId()])) {
$itemAdjustments[$item->getId()] = 0.0;
}
if (Mage::helper('Lokey_PerItemShipping')->getUseQty($product)) {
$itemAdjustments[$item->getId()] += $adjustment * $qty;
} else {
$itemAdjustments[$item->getId()] += $adjustment;
}
}
$adjustments->setItems($itemAdjustments);
}
return $this;
}
示例6: changeTrustedRatingStatus
/**
* Change the status (active, inactive) by sending an api call to Trusted Shops
*
* @param Varien_Event_Observer $observer Observer
*
* @return void
*/
public function changeTrustedRatingStatus($observer)
{
$storeId = $observer->getStore();
$soapUrl = Mage::helper('trustedrating')->getConfig('soapapi', 'url');
$sendData = $this->_getSendData($storeId);
$returnValue = $this->_callTrustedShopsApi($sendData, $soapUrl);
$returnString = Mage::helper('trustedrating')->__('TrustedShops return value: ');
Mage::getSingleton('core/session')->addNotice($returnString . $returnValue);
}
示例7: createByStore
/**
* @param Varien_Event_Observer $observer
*/
public function createByStore(Varien_Event_Observer $observer)
{
/** @var $store Mage_Core_Model_Store */
$store = $observer->getStore();
if (!$store->isObjectNew()) {
return;
}
$service = $this->getFactory()->getServiceConfigPaymentMethodCreate();
$service->executeByStore($store);
}
示例8: calculateAdjustment
public function calculateAdjustment(Varien_Event_Observer $observer)
{
$store = $observer->getStore();
$request = $observer->getRequest();
$allItems = $observer->getAllItems();
$adjustments = $observer->getAdjustments();
$groupAdjustments = array();
$itemAdjustments = $adjustments->getItems();
foreach ($allItems as $item) {
$qty = $item->getQty();
if ($item->getParentItem()) {
$qty *= $item->getParentItem()->getQty();
}
$qty -= $item->getFreeShipping();
$qty = max($qty, 0);
if ($request->getFreeShipping() || $qty === 0) {
continue;
}
$product = Mage::getModel('catalog/product')->setStoreId($store->getId())->load($item->getProductId());
$group = Mage::helper('Lokey_PerGroupShipping/Data')->getAdjustmentGroupByProduct($product);
if (!$product->getTypeInstance()->isVirtual() && $group->getId()) {
$adjustment = max(round($group->getAmount(), 2), 0.0);
switch ($group->getType()) {
case Lokey_PerGroupShipping_Model_System_Config_Source_AdjustmentType::ORDER:
$groupAdjustments[$group->getId()] = $adjustment;
break;
case Lokey_PerGroupShipping_Model_System_Config_Source_AdjustmentType::LINE:
if (!isset($itemAdjustments[$item->getId()])) {
$itemAdjustments[$item->getId()] = 0.0;
}
$itemAdjustments[$item->getId()] += $adjustment;
break;
case Lokey_PerGroupShipping_Model_System_Config_Source_AdjustmentType::UNIT:
default:
if (!isset($itemAdjustments[$item->getId()])) {
$itemAdjustments[$item->getId()] = 0.0;
}
$itemAdjustments[$item->getId()] += $adjustment * $qty;
break;
}
}
}
foreach ($groupAdjustments as $groupAdjustment) {
$adjustments->setOrder($adjustments->getOrder() + $groupAdjustment);
}
$adjustments->setItems($itemAdjustments);
return $this;
}
示例9: 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);
}
}
}
示例10: saveExcludedCmsPages
/**
* Save excluded cms pages for store.
*
* @param Varien_Event_Observer $observer
*/
public function saveExcludedCmsPages(Varien_Event_Observer $observer)
{
Mage::helper("content")->setCmsPageMap($observer->getExcludedPages(), $observer->getStore());
}