Esempio n. 1
0
 /**
  * Create selection price list for the retrieved options
  *
  * @param \Magento\Bundle\Model\Option $option
  * @param Product $bundleProduct
  * @return \Magento\Bundle\Pricing\Price\BundleSelectionPrice[]
  */
 public function createSelectionPriceList($option, $bundleProduct)
 {
     $priceList = [];
     $selections = $option->getSelections();
     if ($selections === null) {
         return $priceList;
     }
     /* @var $selection \Magento\Bundle\Model\Selection|\Magento\Catalog\Model\Product */
     foreach ($selections as $selection) {
         if (!$selection->isSalable()) {
             // @todo CatalogInventory Show out of stock Products
             continue;
         }
         $priceList[] = $this->selectionFactory->create($bundleProduct, $selection, $selection->getSelectionQty());
     }
     return $priceList;
 }
Esempio n. 2
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testCreateException()
 {
     $this->objectManagerMock->expects($this->once())->method('create')->with($this->equalTo(BundleSelectionFactory::SELECTION_CLASS_DEFAULT), $this->equalTo(['test' => 'some value', 'bundleProduct' => $this->bundleMock, 'saleableItem' => $this->selectionMock, 'quantity' => 2.0]))->will($this->returnValue(new \stdClass()));
     $this->bundleSelectionFactory->create($this->bundleMock, $this->selectionMock, 2.0, ['test' => 'some value']);
 }
 /**
  * Get selection amount
  *
  * @param \Magento\Bundle\Model\Selection $selection
  * @return \Magento\Framework\Pricing\Amount\AmountInterface
  */
 public function getOptionSelectionAmount($selection)
 {
     $selectionPrice = $this->selectionFactory->create($this->product, $selection, $selection->getSelectionQty());
     return $selectionPrice->getAmount();
 }