/** * Create inherited child configurations for a Store * * @param Mage_Core_Model_Store $store * * @return Payone_Core_Model_Domain_Config_PaymentMethod[] */ public function executeByStore(Mage_Core_Model_Store $store) { $scope = 'stores'; $scopeId = $store->getStoreId(); $parentId = $store->getWebsiteId(); $this->savePaymentConfigs($scope, $scopeId, $parentId); }
/** * @magentoDataFixture Mage/Core/_files/store.php * @magentoDbIsolation enabled * @dataProvider saveActionDataProvider * @param array $inputData * @param array $defaultAttributes * @param array $attributesSaved */ public function testSaveAction($inputData, $defaultAttributes, $attributesSaved = array()) { $store = new Mage_Core_Model_Store(); $store->load('fixturestore', 'code'); $storeId = $store->getId(); $this->getRequest()->setPost($inputData); $this->getRequest()->setParam('store', $storeId); $this->getRequest()->setParam('id', 2); $this->dispatch('backend/admin/catalog_category/save'); $messages = Mage::getSingleton('Mage_Backend_Model_Session')->getMessages(false)->getItemsByType(Mage_Core_Model_Message::SUCCESS); $this->assertNotEmpty($messages, "Could not save category"); $this->assertEquals('The category has been saved.', current($messages)->getCode()); $category = new Mage_Catalog_Model_Category(); $category->setStoreId($storeId); $category->load(2); $errors = array(); foreach ($attributesSaved as $attribute => $value) { $actualValue = $category->getData($attribute); if ($value !== $actualValue) { $errors[] = "value for '{$attribute}' attribute must be '{$value}', but '{$actualValue}' is found instead"; } } foreach ($defaultAttributes as $attribute => $exists) { if ($exists !== $category->getExistsStoreValueFlag($attribute)) { if ($exists) { $errors[] = "custom value for '{$attribute}' attribute is not found"; } else { $errors[] = "custom value for '{$attribute}' attribute is found, but default one must be used"; } } } $this->assertEmpty($errors, "\n" . join("\n", $errors)); }
/** * Translates a category id stored in the supplied field to a full category path. * * @param array $aRow A flat product row * @param string $vField The name of the filed in which the category id is found. * @param Mage_Core_Model_Store $oStore The store context we're currently exporting. * @return mixed */ public function translate($aRow, $vField, $oStore) { if ($oStore->getId() !== $this->_iStoreId) { $this->_aCategoryPaths = array(); $this->_initCategories($oStore); $this->_iStoreId = $oStore->getId(); } return $this->_getCategoryPath($aRow[$vField]); }
/** * Called once at that the beginning of the export. Used this to perform any * actions required (e.g. loading categories) to set up the process. * * @param Mage_Core_Model_Store $oStore The store context in which this export occurs * @param Mage_Core_Model_Config_Element $oConfig The field mapping for this feed * @return Aligent_Feeds_Model_Googleshopping_Formatter $this */ public function init(Mage_Core_Model_Store $oStore, Mage_Core_Model_Config_Element $oConfig) { $this->_oConfig = $oConfig; $this->_oStore = $oStore; $this->_vBaseUrl = $oStore->getBaseUrl(); $this->_vMediaBaseUrl = $oStore->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); $this->_vProductMediaBaseUrl = $this->_vMediaBaseUrl . 'catalog/product'; return $this; }
/** * Test Soap server construction with WSDL cache disabling. */ public function testConstructDisableWsdlCache() { /** Mock getConfig method to return false. */ $this->_storeMock->expects($this->any())->method('getConfig')->will($this->returnValue(false)); /** Create Soap server object. */ $server = new Mage_Webapi_Model_Soap_Server($this->_applicationMock, $this->_requestMock, $this->_domDocumentFactory); $server->initWsdlCache(); /** Assert soap wsdl caching option was disabled after soap server initialization. */ $this->assertFalse((bool) ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not disabled.'); }
/** * Function retrieves extension stored in Magento configuration. * Default in category extension. * @param Mage_Core_Model_Store $store */ public function getExtension($store) { if (!isset($store) || !$store) { return Mage::getStoreConfig('catalog/seo/category_url_suffix'); } $extension = Mage::getStoreConfig('catalog/seo/category_url_suffix', $store->getId()); if (isset($extension) && $extension != '' && $extension[0] == '.') { $extension = '\\' . $extension; } return $extension; }
/** * @param Mage_Core_Model_Store $store */ protected function _flushAllSpecialPrices($store) { /** @var Mage_Catalog_Model_Resource_Product_Collection $products */ $products = Mage::getResourceModel('catalog/product_collection')->setStoreId($store->getId())->addAttributeToFilter('special_from_date', array('lteq' => now(true)))->addAttributeToFilter(array(array('attribute' => 'special_to_date', 'gteq' => now(true)), array('attribute' => 'special_to_date', 'null' => true)))->addWebsiteFilter($store->getWebsiteId()); $size = $products->getSize(); if ($size) { $msg = sprintf('process store %s and %s product(s) with all special prices', $store->getCode(), $size); Mage::getSingleton('core/resource_iterator')->walk($products->getSelect(), array(array($this, 'iteratorCallback')), array('size' => $size, 'msg' => $msg, 'store' => $store)); echo PHP_EOL; } }
/** * @param Adyen_Subscription_Model_Product_Subscription $subscription * @param Mage_Core_Model_Store|int $store * @return $this */ public function loadBySubscription(Adyen_Subscription_Model_Product_Subscription $subscription, $store) { $labels = $this->getCollection()->addFieldToFilter('subscription_id', $subscription->getId()); if ($store instanceof Mage_Core_Model_Store) { $storeId = $store->getId(); } else { $storeId = $store; } $labels->addFieldToFilter('store_id', $storeId); return $labels->getFirstItem(); }
/** * @param Result $result * @param \Mage_Core_Model_Store $store * @param string $baseUrl setting */ protected function checkSettings(Result $result, \Mage_Core_Model_Store $store, $baseUrl) { $errorMessage = 'Wrong hostname configured. <info>Hostname must contain a dot</info>'; $host = parse_url($baseUrl, PHP_URL_HOST); $isValid = (bool) strstr($host, '.'); $result->setStatus($isValid); if ($isValid) { $result->setMessage('<info>' . ucfirst($this->class) . ' BaseURL: <comment>' . $baseUrl . '</comment> of Store: <comment>' . $store->getCode() . '</comment> - OK'); } else { $result->setMessage('<error>Invalid ' . ucfirst($this->class) . ' BaseURL: <comment>' . $baseUrl . '</comment> of Store: <comment>' . $store->getCode() . '</comment> ' . $errorMessage . '</error>'); } }
/** * Translates a category id stored in the supplied field to a full category path. * * @param array $aRow A flat product row * @param string $vField The name of the filed in which the category id is found. * @param Mage_Core_Model_Store $oStore The store context we're currently exporting. * @return mixed */ public function translate($aRow, $vField, $oStore) { if ($oStore->getId() !== $this->_iStoreId) { $this->_iDefaultCondition = Mage::getStoreConfig(self::CONFIG_CONDITION, $oStore->getId()); $this->_iStoreId = $oStore->getId(); } $vFieldValue = false; if (array_key_exists($vField, $aRow)) { $vFieldValue = $aRow[$vField]; } return Mage::getSingleton('aligent_feeds/source_condition')->getGoogleValue($vFieldValue ? $vFieldValue : $this->_iDefaultCondition); }
/** * Retrieve request_path using id_path and current store's id. * * @param string $idPath * @param int|Mage_Core_Model_Store $store * @return string|false */ public function getRequestPathByIdPath($idPath, $store) { if ($store instanceof Mage_Core_Model_Store) { $storeId = (int) $store->getId(); } else { $storeId = (int) $store; } $select = $this->_getReadAdapter()->select(); /* @var $select Zend_Db_Select */ $select->from(array('main_table' => $this->getMainTable()), 'request_path')->where('main_table.store_id = ?', $storeId)->where('main_table.id_path = ?', $idPath)->limit(1); return $this->_getReadAdapter()->fetchOne($select); }
public function testGetProductNrRiskCheckAdvanced() { $path = 'scoring/buergel/services'; $this->store->resetConfig(); $this->store->setConfig($path, Netresearch_Buergel_Model_System_Source_Service::RISKCHECK_ADVANCED); $this->config = Mage::getModel('buergel/config'); $this->config->reset(); $this->config->setIsCompanyAddress(false); $this->assertEquals(Netresearch_Buergel_Model_System_Source_Service::RISKCHECK_ADVANCED, $this->config->getProductNr()); $this->config->setIsCompanyAddress(); $this->assertEquals(Netresearch_Buergel_Model_System_Source_Service::RISKCHECK_ADVANCED, $this->config->getProductNr()); $this->config->reset(); }
/** * Retrieve store Id * * @return int */ public function getStoreId() { if (is_null($this->_store)) { try { $this->_store = Mage::app()->getStore($this->getVar('store')); } catch (Exception $e) { $message = Mage::helper('eav')->__('Invalid store specified'); $this->addException($message, Varien_Convert_Exception::FATAL); throw $e; } } return $this->_store->getId(); }
/** * @return string */ protected function _parseException($node, \Mage_Core_Model_Store $store) { $exception = (string) \Mage::getConfig()->getNode($node . self::THEMES_EXCEPTION, AbstractMagentoStoreConfigCommand::SCOPE_STORE_VIEW, $store->getCode()); if (empty($exception)) { return ''; } $exceptions = unserialize($exception); $result = array(); foreach ($exceptions as $expression) { $result[] = 'Matched Expression: ' . $expression['regexp']; $result[] = 'Value: ' . $expression['value']; } return implode("\n", $result); }
/** * Get the dashboard rep id, if applicable * null otherwise * * @param Mage_Core_Model_Store * @return string|null */ public function getDashboardRepId(Mage_Core_Model_Store $store) { if ($store->isAdmin()) { $adminSession = $this->_getAdminSession(); $csr = $adminSession->getCustomerServiceRep() ?: Mage::getModel('eb2ccsr/representative'); $repId = $csr->getRepId(); if ($repId) { return $repId; } $adminUser = $adminSession->getUser(); return $adminUser ? $adminUser->getUsername() : null; } return null; }
/** * @param Result $result * @param \Mage_Core_Model_Store $store * @param string $baseUrl setting * @param string $cookieDomain setting */ protected function checkSettings(Result $result, \Mage_Core_Model_Store $store, $baseUrl, $cookieDomain) { $errorMessage = 'cookie-domain and ' . $this->class . ' base-URL do not match'; if (strlen($cookieDomain)) { $isValid = $this->validateCookieDomainAgainstUrl($cookieDomain, $baseUrl); $result->setStatus($isValid); if ($isValid) { $result->setMessage('<info>Cookie Domain (' . $this->class . '): <comment>' . $cookieDomain . '</comment> of Store: <comment>' . $store->getCode() . '</comment> - OK</info>'); } else { $result->setMessage('<error>Cookie Domain (' . $this->class . '): <comment>' . $cookieDomain . '</comment> of Store: <comment>' . $store->getCode() . '</comment> - ERROR: ' . $errorMessage . '</error>'); } } else { $result->setMessage('<info>Empty cookie Domain (' . $this->class . ') of Store: <comment>' . $store->getCode() . '</comment> - OK</info>'); } }
/** * Create a Klevu Webstore using the API for the given Magento store. * * @param $customer_id * @param Mage_Core_Model_Store $store * @param bool $test_mode * * @return array An array with the following keys: * success: boolean value indicating whether the operation was successful. * webstore: (success only) Varien_Object containing Webstore information. * message: message to be displayed to the user. */ public function createWebstore($customer_id, Mage_Core_Model_Store $store, $test_mode = false) { $name = sprintf("%s - %s - %s", $store->getWebsite()->getName(), $store->getName(), $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)); $language = Mage::helper("klevu_search")->getStoreLanguage($store); $timezone = $store->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); // Convert $test_mode to string $test_mode = $test_mode ? "true" : "false"; $response = Mage::getModel("klevu_search/api_action_addwebstore")->execute(array("customerId" => $customer_id, "storeName" => $name, "language" => $language, "timezone" => $timezone, "testMode" => $test_mode)); if ($response->isSuccessful()) { $webstore = new Varien_Object(array("store_name" => $name, "js_api_key" => $response->getJsApiKey(), "rest_api_key" => $response->getRestApiKey(), "test_account_enabled" => $test_mode)); return array("success" => true, "webstore" => $webstore, "message" => $response->getMessage()); } else { return array("success" => false, "message" => $response->getMessage()); } }
/** * Calculate item fixed tax and prepare information for discount and recular taxation * * @param Mage_Sales_Model_Quote_Address $address * @param Mage_Sales_Model_Quote_Item_Abstract $item * @return Mage_Weee_Model_Total_Quote_Weee */ protected function _process(Mage_Sales_Model_Quote_Address $address, $item) { if (!$this->_helper->isEnabled($this->_store)) { return $this; } $attributes = $this->_helper->getProductWeeeAttributes($item->getProduct(), $address, $address->getQuote()->getBillingAddress(), $this->_store->getWebsiteId()); $applied = array(); $productTaxes = array(); $totalValue = 0; $baseTotalValue = 0; $totalRowValue = 0; $baseTotalRowValue = 0; foreach ($attributes as $k => $attribute) { $baseValue = $attribute->getAmount(); $value = $this->_store->convertPrice($baseValue); $rowValue = $value * $item->getTotalQty(); $baseRowValue = $baseValue * $item->getTotalQty(); $title = $attribute->getName(); $totalValue += $value; $baseTotalValue += $baseValue; $totalRowValue += $rowValue; $baseTotalRowValue += $baseRowValue; $productTaxes[] = array('title' => $title, 'base_amount' => $baseValue, 'amount' => $value, 'row_amount' => $rowValue, 'base_row_amount' => $baseRowValue, 'base_amount_incl_tax' => $baseValue, 'amount_incl_tax' => $value, 'row_amount_incl_tax' => $rowValue, 'base_row_amount_incl_tax' => $baseRowValue); $applied[] = array('id' => $attribute->getCode(), 'percent' => null, 'hidden' => $this->_helper->includeInSubtotal($this->_store), 'rates' => array(array('base_real_amount' => $baseRowValue, 'base_amount' => $baseRowValue, 'amount' => $rowValue, 'code' => $attribute->getCode(), 'title' => $title, 'percent' => null, 'position' => 1, 'priority' => -1000 + $k))); } $item->setWeeeTaxAppliedAmount($totalValue)->setBaseWeeeTaxAppliedAmount($baseTotalValue)->setWeeeTaxAppliedRowAmount($totalRowValue)->setBaseWeeeTaxAppliedRowAmount($baseTotalRowValue); $this->_processTaxSettings($item, $totalValue, $baseTotalValue, $totalRowValue, $baseTotalRowValue)->_processTotalAmount($address, $totalRowValue, $baseTotalRowValue); $this->_helper->setApplied($item, array_merge($this->_helper->getApplied($item), $productTaxes)); if ($applied) { $this->_saveAppliedTaxes($address, $applied, $item->getWeeeTaxAppliedAmount(), $item->getBaseWeeeTaxAppliedAmount(), null); } }
/** * Delete content of media/js and media/css folders to refresh with updated compressed/minified js/css content * If disabled, the updates are done each time an original file is updated. Can be resource overload on live website. * * @param Mage_Core_Model_Observer $observer */ public function regenerateMediaFiles($observer) { if (Mage::getStoreConfigFlag('uioptimization/general/cronupdate') && (Mage::getStoreConfigFlag('uioptimization/csscompression/enabled') || Mage::getStoreConfigFlag('uioptimization/jscompression/enabled'))) { // Clean up media/css and media/js folders and recreate the folders if necessary try { Mage::getModel('core/design_package')->cleanMergedJsCss(); Mage::dispatchEvent('clean_media_cache_after'); } catch (Exception $e) { Mage::logException($e); return; } $stores = Mage::app()->getStores(); foreach ($stores as $id => $v) { $url = Zend_Uri_Http::fromString(Mage::app()->getStore($id)->getBaseUrl()); // Recreate the js and css compressed file by using the normal process try { $curl = new Zend_Http_Client_Adapter_Curl(); $curl->setCurlOption(CURLOPT_SSL_VERIFYPEER, false); $curl->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1); $curl->connect($url->getHost(), $url->getPort(), Mage_Core_Model_Store::isCurrentlySecure()); $curl->write(Zend_Http_Client::GET, $url); $curl->close(); Mage::log('[Diglin_UIOptimization_Model_Observer] Update media js/css content for the different stores', ZEND_LOG::DEBUG); } catch (Exception $e) { Mage::logException($e); return; } } } }
public function getCurrentUrl($fromStore = true) { $sidQueryParam = $this->_getSession()->getSessionIdQueryParam(); $storeUrl = Mage::app()->getStore()->isCurrentlySecure() ? $this->getUrl('', array('_secure' => true)) : $this->getUrl(''); $storeParsedUrl = parse_url($storeUrl); $params = array('_current' => true, '_m_escape' => '', '_use_rewrite' => true, '_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()); $currentUrl = Mage::getUrl('*/*/*', $params); if (($pos = strpos($currentUrl, '?')) !== false) { $currentUrl = substr($currentUrl, 0, $pos); } $requestString = ltrim(Mage::app()->getRequest()->getRequestString(), '/'); $storeParsedQuery = array(); if (isset($storeParsedUrl['query'])) { parse_str($storeParsedUrl['query'], $storeParsedQuery); } $currQuery = Mage::app()->getRequest()->getQuery(); if (isset($currQuery[$sidQueryParam]) && !empty($currQuery[$sidQueryParam]) && $this->_getSession()->getSessionIdForHost($storeUrl) != $currQuery[$sidQueryParam]) { unset($currQuery[$sidQueryParam]); } foreach ($currQuery as $k => $v) { $storeParsedQuery[$k] = $v; } if (!Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL, $this->getCode())) { $storeParsedQuery['___store'] = $this->getCode(); } //if ($fromStore !== false) { $storeParsedQuery['___from_store'] = $fromStore === true ? Mage::app()->getStore()->getCode() : $fromStore; //} return $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host'] . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '') . $storeParsedUrl['path'] . $requestString . ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : ''); return Mage::helper('mana_filters')->markLayeredNavigationUrl(Mage::getUrl('*/*/*', $params), '*/*/*', $params); /* @var $url Mana_Seo_Rewrite_Url */ $url = Mage::getSingleton('core/url'); return $url->getUrl('*/*/*', parent::getCurrentUrl($fromStore)); }
/** * @loadFixture ../../../var/fixtures/customers.yaml * @loadFixture ../../../var/fixtures/orders.yaml */ public function testCanShowRetoureLink() { $this->setUp(); $this->store->setConfig('intraship/dhlonlineretoure/active', '1'); $customerId = 4; $orderId = 12; /* @var $customer Mage_Customer_Model_Customer */ $customer = Mage::getModel("customer/customer")->load($customerId); /* @var $order Mage_Sales_Model_Order */ $order = Mage::getModel("sales/order")->load($orderId); //Default case, no parameters given $this->assertFalse($this->getValidateHelper()->canShowRetoureLink($order)); // internal request Mage::app()->getRequest()->setParam('hash', '1'); $this->assertFalse($this->getValidateHelper()->canShowRetoureLink($order)); // external request Mage::app()->getRequest()->clearParams(); Mage::app()->getRequest()->setParam('order_id', $orderId); // prepare customer for retoure link $session = $this->getModelMock('customer/session', array('isLoggedIn', 'init', 'renewSession', 'start')); $session->expects($this->any())->method('isLoggedIn')->will($this->returnValue(true)); $this->replaceByMock('singleton', 'customer/session', $session); $customerHelper = $this->getHelperMock('customer/data', array('getCustomer')); $customerHelper->expects($this->any())->method('getCustomer')->will($this->returnValue($customer)); $this->replaceByMock('helper', 'customer/data', $customerHelper); // prepare config settings for retoure link $deliveryIso = $order->getShippingAddress()->getCountryId(); $deliveryName = 'Delivery' . $deliveryIso; $data = array(array('iso' => $deliveryIso, 'name' => $deliveryName)); $this->store->setConfig('intraship/dhlonlineretoure/delivery_names', serialize($data)); $this->store->setConfig('intraship/dhlonlineretoure/allowed_shipping_methods', "flatrate_flatrate"); $this->assertTrue($this->getValidateHelper()->canShowRetoureLink($order)); }
/** * Calculate item fixed tax and prepare information for discount and recular taxation * * @param Mage_Sales_Model_Quote_Address $address * @param Mage_Sales_Model_Quote_Item_Abstract $item * @return Mage_Weee_Model_Total_Quote_Weee */ protected function _process(Mage_Sales_Model_Quote_Address $address, $item) { if (!$this->_helper->isEnabled($this->_store)) { return $this; } $attributes = $this->_helper->getProductWeeeAttributes($item->getProduct(), $address, $address->getQuote()->getBillingAddress(), $this->_store->getWebsiteId()); $applied = array(); $productTaxes = array(); $totalValue = 0; $baseTotalValue = 0; $totalRowValue = 0; $baseTotalRowValue = 0; $totalExclTaxValue = 0; $baseTotalExclTaxValue = 0; $totalExclTaxRowValue = 0; $baseTotalExclTaxRowValue = 0; $customerRatePercentage = $this->_customerRatePercent($address, $item); foreach ($attributes as $k => $attribute) { $baseValue = $attribute->getAmount(); $baseValueExclTax = $baseValue; if ($customerRatePercentage && $this->_helper->isTaxIncluded($this->_store)) { //Remove the customer tax. This in general applies to EU scenario $baseValueExclTax = $this->_getCalculator()->round($baseValue * 100 / (100 + $customerRatePercentage)); } $value = $this->_store->convertPrice($baseValue); $rowValue = $value * $item->getTotalQty(); $baseRowValue = $baseValue * $item->getTotalQty(); //Get the values excluding tax $valueExclTax = $this->_store->convertPrice($baseValueExclTax); $rowValueExclTax = $valueExclTax * $item->getTotalQty(); $baseRowValueExclTax = $baseValueExclTax * $item->getTotalQty(); $title = $attribute->getName(); //Calculate the Wee value $totalValue += $value; $baseTotalValue += $baseValue; $totalRowValue += $rowValue; $baseTotalRowValue += $baseRowValue; //Calculate the Wee without tax $totalExclTaxValue += $valueExclTax; $baseTotalExclTaxValue += $baseValueExclTax; $totalExclTaxRowValue += $rowValueExclTax; $baseTotalExclTaxRowValue += $baseRowValueExclTax; /* * Note: including Tax does not necessarily mean it includes all the tax * *_incl_tax only holds the tax associated with Tax included products */ $productTaxes[] = array('title' => $title, 'base_amount' => $baseValueExclTax, 'amount' => $valueExclTax, 'row_amount' => $rowValueExclTax, 'base_row_amount' => $baseRowValueExclTax, 'base_amount_incl_tax' => $baseValue, 'amount_incl_tax' => $value, 'row_amount_incl_tax' => $rowValue, 'base_row_amount_incl_tax' => $baseRowValue); $applied[] = array('id' => $attribute->getCode(), 'percent' => null, 'hidden' => $this->_helper->includeInSubtotal($this->_store), 'rates' => array(array('base_real_amount' => $baseRowValue, 'base_amount' => $baseRowValue, 'amount' => $rowValue, 'code' => $attribute->getCode(), 'title' => $title, 'percent' => null, 'position' => 1, 'priority' => -1000 + $k))); } //We set the TAX exclusive value $item->setWeeeTaxAppliedAmount($totalExclTaxValue); $item->setBaseWeeeTaxAppliedAmount($baseTotalExclTaxValue); $item->setWeeeTaxAppliedRowAmount($totalExclTaxRowValue); $item->setBaseWeeeTaxAppliedRowAmount($baseTotalExclTaxRowValue); $this->_processTaxSettings($item, $totalExclTaxValue, $baseTotalExclTaxValue, $totalExclTaxRowValue, $baseTotalExclTaxRowValue)->_processTotalAmount($address, $totalExclTaxRowValue, $baseTotalExclTaxRowValue); $this->_helper->setApplied($item, array_merge($this->_helper->getApplied($item), $productTaxes)); if ($applied) { $this->_saveAppliedTaxes($address, $applied, $item->getWeeeTaxAppliedAmount(), $item->getBaseWeeeTaxAppliedAmount(), null); } }
/** * Round price considering delta * * @param float $price * @param bool $negative Indicates if we perform addition (true) or subtraction (false) of rounded value * @return float */ public function deltaRound($price, $negative = false) { $roundedPrice = $price; if ($roundedPrice) { if ($negative) { $this->_delta = -$this->_delta; } $price += $this->_delta; $roundedPrice = $this->_store->roundPrice($price); $this->_delta = $price - $roundedPrice; if ($negative) { $this->_delta = -$this->_delta; } } return $roundedPrice; }
/** * Test getEndpointUri method. */ public function testGetEndpointUri() { $this->_storeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://magento.com/')); $expectedResult = 'http://magento.com/' . Mage_Webapi_Controller_Router_Route_Webapi::API_AREA_NAME . '/' . Mage_Webapi_Controller_Front::API_TYPE_SOAP; $actualResult = $this->_soapServer->getEndpointUri(); $this->assertEquals($expectedResult, $actualResult, 'Wrong endpoint URI building.'); }
/** * @magentoAppIsolation enabled */ public function testCRUD() { $this->_model->setData(array('code' => 'test', 'website_id' => 1, 'group_id' => 1, 'name' => 'test name', 'sort_order' => 0, 'is_active' => 1)); /* emulate admin store */ Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID); $crud = new Magento_Test_Entity($this->_model, array('name' => 'new name')); $crud->testCrud(); }
protected function _getDefaultStore() { if (empty($this->_store)) { $this->_store = new Mage_Core_Model_Store(); $this->_store->setStoreId(1)->setCode('default'); } return $this->_store; }
/** * @covers Mage_Core_Model_Website::setGroups * @covers Mage_Core_Model_Website::setStores * @covers Mage_Core_Model_Website::getStores */ public function testSetGroupsAndStores() { /* Groups */ $expectedGroup = new Mage_Core_Model_Store_Group(); $expectedGroup->setId(123); $this->_model->setDefaultGroupId($expectedGroup->getId()); $this->_model->setGroups(array($expectedGroup)); $groups = $this->_model->getGroups(); $this->assertSame($expectedGroup, reset($groups)); /* Stores */ $expectedStore = new Mage_Core_Model_Store(); $expectedStore->setId(456); $expectedGroup->setDefaultStoreId($expectedStore->getId()); $this->_model->setStores(array($expectedStore)); $stores = $this->_model->getStores(); $this->assertSame($expectedStore, reset($stores)); }
public function setData($key, $value = null) { parent::setData($key, $value); if ($this->getStoreId() && $this->store && $this->store->getId() != $this->getStoreId()) { $this->store = null; } return $this; }
/** * Update default store currency code * * @return string */ public function getDefaultCurrencyCode() { if (Mage::helper('autocurrency')->isEnabled()) { $result = $this->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT); return $this->getCurrencyCodeByIp($result); } else { return parent::getDefaultCurrencyCode(); } }
/** * @param string $key * @return mixed */ protected function getConfig($key) { if (isset($this->_store)) { $storeId = $this->_store->getId(); } else { $storeId = null; } return Mage::getStoreConfig('mehulchaudhari_feedsgenerator/' . $this->_configPath . '/' . $key, $storeId); }