Exemplo n.º 1
0
 /**
  * @param \Magento\Quote\Model\Quote\Address $address
  * @return bool
  */
 public function isCanApplyMsrp($address)
 {
     $canApplyMsrp = false;
     foreach ($address->getAllItems() as $item) {
         if (!$item->getParentItemId() && $this->msrpHelper->isShowBeforeOrderConfirm($item->getProductId()) && $this->msrpHelper->isMinimalPriceLessMsrp($item->getProductId())) {
             $canApplyMsrp = true;
             break;
         }
     }
     return $canApplyMsrp;
 }
Exemplo n.º 2
0
 public function testIsMinimalPriceLessMsrp()
 {
     $msrp = 120;
     $convertedFinalPrice = 200;
     $this->priceCurrencyMock->expects($this->any())->method('convertAndRound')->will($this->returnCallback(function ($arg) {
         return round(2 * $arg, 2);
     }));
     $finalPriceMock = $this->getMockBuilder('\\Magento\\Catalog\\Pricing\\Price\\FinalPrice')->disableOriginalConstructor()->getMock();
     $finalPriceMock->expects($this->any())->method('getValue')->will($this->returnValue($convertedFinalPrice));
     $priceInfoMock = $this->getMockBuilder('\\Magento\\Framework\\Pricing\\PriceInfo\\Base')->disableOriginalConstructor()->getMock();
     $priceInfoMock->expects($this->once())->method('getPrice')->with(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)->will($this->returnValue($finalPriceMock));
     $this->productMock->expects($this->any())->method('getMsrp')->will($this->returnValue($msrp));
     $this->productMock->expects($this->any())->method('getPriceInfo')->will($this->returnValue($priceInfoMock));
     $result = $this->helper->isMinimalPriceLessMsrp($this->productMock);
     $this->assertTrue($result, "isMinimalPriceLessMsrp returned incorrect value");
 }
Exemplo n.º 3
0
 /**
  * Collect information about MSRP price enabled
  *
  * @param  \Magento\Quote\Model\Quote\Address $address
  * @return $this
  * @api
  */
 public function collect(\Magento\Quote\Model\Quote\Address $address)
 {
     parent::collect($address);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $canApplyMsrp = false;
     foreach ($items as $item) {
         if (!$item->getParentItemId() && $this->msrpData->isShowBeforeOrderConfirm($item->getProductId()) && $this->msrpData->isMinimalPriceLessMsrp($item->getProductId())) {
             $canApplyMsrp = true;
             break;
         }
     }
     $address->setCanApplyMsrp($canApplyMsrp);
     return $this;
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 protected function doGetItemData()
 {
     $imageHelper = $this->imageHelper->init($this->getProductForThumbnail(), 'mini_cart_product_thumbnail');
     return ['options' => $this->getOptionList(), 'qty' => $this->item->getQty() * 1, 'item_id' => $this->item->getId(), 'configure_url' => $this->getConfigureUrl(), 'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(), 'product_name' => $this->item->getProduct()->getName(), 'product_url' => $this->getProductUrl(), 'product_has_url' => $this->hasProductUrl(), 'product_price' => $this->checkoutHelper->formatPrice($this->item->getCalculationPrice()), 'product_image' => ['src' => $imageHelper->getUrl(), 'alt' => $imageHelper->getLabel(), 'width' => $imageHelper->getWidth(), 'height' => $imageHelper->getHeight()], 'canApplyMsrp' => $this->msrpHelper->isShowBeforeOrderConfirm($this->item->getProduct()) && $this->msrpHelper->isMinimalPriceLessMsrp($this->item->getProduct())];
 }
Exemplo n.º 5
0
 /**
  * @param Product $product
  * @return bool|float
  */
 public function isMinimalPriceLessMsrp(Product $product)
 {
     return $this->msrpData->isMinimalPriceLessMsrp($product);
 }