Esempio n. 1
0
 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Product $product
  * @param Entry $entry
  * @return Entry
  */
 public function convertAttribute($product, $entry)
 {
     $product->setWebsiteId($this->_storeManager->getStore($product->getStoreId())->getWebsiteId());
     $defaultCustomerGroup = $this->_customerGroupService->getDefaultGroup($product->getStoreId());
     $product->setCustomerGroupId($defaultCustomerGroup->getId());
     /** @var \Magento\Store\Model\Store $store */
     $store = $this->_storeManager->getStore($product->getStoreId());
     $isSalePriceAllowed = $this->_config->getTargetCountry($product->getStoreId()) == 'US';
     // get tax settings
     $priceDisplayType = $this->_taxData->getPriceDisplayType($product->getStoreId());
     $inclTax = $priceDisplayType == Config::DISPLAY_TYPE_INCLUDING_TAX;
     $finalPrice = $this->_getFinalPrice($product, $store, $inclTax, $isSalePriceAllowed);
     // calculate price attribute value
     $price = $this->_getPrice($product, $store, $priceDisplayType, $inclTax, $isSalePriceAllowed);
     if ($isSalePriceAllowed) {
         // set sale_price and effective dates for it
         if ($price && $price - $finalPrice > 0.0001) {
             $this->_setAttributePrice($entry, $product, $price);
             $this->_setAttributePrice($entry, $product, $finalPrice, 'sale_price');
             $this->_setEffectiveDate($product, $entry);
         } else {
             $this->_setAttributePrice($entry, $product, $finalPrice);
             $entry->removeContentAttribute('sale_price_effective_date');
             $entry->removeContentAttribute('sale_price');
         }
         // calculate taxes
         $tax = $this->getGroupAttributeTax();
         if (!$inclTax && !is_null($tax)) {
             $tax->convertAttribute($product, $entry);
         }
     } else {
         $this->_setAttributePrice($entry, $product, $price);
     }
     return $entry;
 }
Esempio n. 2
0
 /**
  * Get tax price display settings
  *
  * @param  null|string|bool|int|Store $store
  * @return int
  */
 public function getTaxDisplayConfig($store = null)
 {
     return $this->_taxData->getPriceDisplayType($store);
 }