예제 #1
0
 /**
  * Retrieve an item instance to the configured price model
  *
  * @return $this
  */
 protected function _prepareLayout()
 {
     /** @var $price \Magento\Bundle\Pricing\Price\ConfiguredPrice */
     $price = $this->getPrice();
     /** @var $renderBlock \Magento\Catalog\Pricing\Render */
     $renderBlock = $this->getRenderBlock();
     if ($renderBlock && $renderBlock->getItem() instanceof ItemInterface) {
         $price->setItem($renderBlock->getItem());
     } elseif ($renderBlock && $renderBlock->getParentBlock() && $renderBlock->getParentBlock()->getItem() instanceof ItemInterface) {
         $price->setItem($renderBlock->getParentBlock()->getItem());
     }
     return parent::_prepareLayout();
 }
예제 #2
0
 public function testShowMinimalPrice()
 {
     $finalPrice = 10.0;
     $minimalPrice = 5.0;
     $displayMininmalPrice = 2.0;
     $this->object->setDisplayMinimalPrice($displayMininmalPrice);
     $finalPriceType = $this->getMock('Magento\\Catalog\\Pricing\\Price\\FinalPrice', [], [], '', false);
     $finalPriceAmount = $this->getMockForAbstractClass('Magento\\Framework\\Pricing\\Amount\\AmountInterface');
     $minimalPriceAmount = $this->getMockForAbstractClass('Magento\\Framework\\Pricing\\Amount\\AmountInterface');
     $finalPriceAmount->expects($this->once())->method('getValue')->will($this->returnValue($finalPrice));
     $minimalPriceAmount->expects($this->once())->method('getValue')->will($this->returnValue($minimalPrice));
     $finalPriceType->expects($this->at(0))->method('getAmount')->will($this->returnValue($finalPriceAmount));
     $finalPriceType->expects($this->at(1))->method('getMinimalPrice')->will($this->returnValue($minimalPriceAmount));
     $this->priceInfo->expects($this->once())->method('getPrice')->with(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)->will($this->returnValue($finalPriceType));
     $this->assertTrue($this->object->showMinimalPrice());
 }
예제 #3
0
 public function testHidePrice()
 {
     $this->product->expects($this->any())->method('getCanShowPrice')->will($this->returnValue(false));
     $this->assertEmpty($this->object->toHtml());
 }
예제 #4
0
 public function testGetCacheKeyInfo()
 {
     $this->assertArrayHasKey('display_minimal_price', $this->object->getCacheKeyInfo());
 }