/** * 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(); }
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()); }
public function testHidePrice() { $this->product->expects($this->any())->method('getCanShowPrice')->will($this->returnValue(false)); $this->assertEmpty($this->object->toHtml()); }
public function testGetCacheKeyInfo() { $this->assertArrayHasKey('display_minimal_price', $this->object->getCacheKeyInfo()); }