Пример #1
0
 private function getProductTaxClassId()
 {
     $proxyOrder = $this->proxyItem->getProxyOrder();
     $taxRate = $this->proxyItem->getTaxRate();
     $hasRatesForCountry = Mage::getSingleton('M2ePro/Magento_Tax_Helper')->hasRatesForCountry($this->quote->getShippingAddress()->getCountryId());
     $calculationBasedOnOrigin = Mage::getSingleton('M2ePro/Magento_Tax_Helper')->isCalculationBasedOnOrigin($this->quote->getStore());
     if ($proxyOrder->isTaxModeNone() || $proxyOrder->isTaxModeChannel() && $taxRate == 0 || $proxyOrder->isTaxModeMagento() && !$hasRatesForCountry && !$calculationBasedOnOrigin) {
         return Ess_M2ePro_Model_Magento_Product::TAX_CLASS_ID_NONE;
     }
     if ($proxyOrder->isTaxModeMagento() || $taxRate == 0 || $taxRate == $this->getProductTaxRate()) {
         return $this->getProduct()->getTaxClassId();
     }
     // Create tax rule according to channel tax rate
     // -------------------------
     /** @var $taxRuleBuilder Ess_M2ePro_Model_Magento_Tax_Rule_Builder */
     $taxRuleBuilder = Mage::getModel('M2ePro/Magento_Tax_Rule_Builder');
     $taxRuleBuilder->buildTaxRule($taxRate, $this->quote->getShippingAddress()->getCountryId(), $this->quote->getCustomerTaxClassId());
     $taxRule = $taxRuleBuilder->getRule();
     $productTaxClasses = $taxRule->getProductTaxClasses();
     // -------------------------
     return array_shift($productTaxClasses);
 }