9 use \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
17 private $tierPriceFactory;
22 $this->tierPriceFactory = $this->objectManager->create(ProductTierPriceInterfaceFactory::class);
33 public function testPriceForDynamicBundle(array $strategyModifiers, array $expectedResults)
36 $bundleProduct = $this->productRepository->get(
'bundle_product',
false,
null,
true);
43 $expectedResults[
'minimalPrice'],
44 $priceInfo->getPrice($priceCode)->getMinimalPrice()->getValue(),
45 'Failed to check minimal price on product' 48 $expectedResults[
'maximalPrice'],
49 $priceInfo->getPrice($priceCode)->getMaximalPrice()->getValue(),
50 'Failed to check maximal price on product' 53 $priceInfoFromIndexer = $this->productCollectionFactory->create()
54 ->addFieldToFilter(
'sku',
'bundle_product')
59 $this->assertEquals($expectedResults[
'minimalPrice'], $priceInfoFromIndexer->getMinimalPrice());
60 $this->assertEquals($expectedResults[
'maximalPrice'], $priceInfoFromIndexer->getMaxPrice());
72 #1 Testing product price for dynamic bundle 73 with one required option and tier price 75 'strategy' => $this->getBundleConfiguration1(),
76 'expectedResults' => [
85 #2 Testing product price for dynamic bundle 86 with one non required option and tier price 88 'strategy' => $this->getBundleConfiguration2(),
89 'expectedResults' => [
98 #3 Testing product price for dynamic bundle 99 with one required checkbox type option and tier price 101 'strategy' => $this->getBundleConfiguration3(),
102 'expectedResults' => [
106 'maximalPrice' => 35,
111 #4 Testing product price for dynamic bundle 112 with one required multi type option and tier price 114 'strategy' => $this->getBundleConfiguration4(),
115 'expectedResults' => [
119 'maximalPrice' => 35,
124 #5 Testing product price for dynamic bundle 125 with one required radio type option and tier price 127 'strategy' => $this->getBundleConfiguration5(),
128 'expectedResults' => [
132 'maximalPrice' => 30,
138 #6 Testing product price for dynamic bundle 139 with two required options and tier price 141 'strategy' => $this->getBundleConfiguration6(),
142 'expectedResults' => [
144 'minimalPrice' => 10,
146 'maximalPrice' => 65,
151 #7 Testing product price for dynamic bundle 152 with one required option, one non required option and tier price 154 'strategy' => $this->getBundleConfiguration7(),
155 'expectedResults' => [
159 'maximalPrice' => 65,
164 #8 Testing product price for dynamic bundle 165 with two non required options and tier price 167 'strategy' => $this->getBundleConfiguration8(),
168 'expectedResults' => [
172 'maximalPrice' => 65,
177 #9 Testing product price for dynamic bundle 178 with tier price and with simple with tier price 180 'strategy' => $this->getBundleConfiguration9(),
181 'expectedResults' => [
183 'minimalPrice' => 1.25,
185 'maximalPrice' => 30,
195 private function getBundleConfiguration1()
201 'type' =>
'checkbox',
215 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
220 'modifierName' =>
'addTierPrice',
224 'modifierName' =>
'addSimpleProduct',
234 private function getBundleConfiguration2()
239 'type' =>
'checkbox',
254 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
259 'modifierName' =>
'addTierPrice',
263 'modifierName' =>
'addSimpleProduct',
273 private function getBundleConfiguration3()
279 'type' =>
'checkbox',
297 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
302 'modifierName' =>
'addTierPrice',
306 'modifierName' =>
'addSimpleProduct',
316 private function getBundleConfiguration4()
340 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
345 'modifierName' =>
'addTierPrice',
349 'modifierName' =>
'addSimpleProduct',
359 private function getBundleConfiguration5()
383 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
388 'modifierName' =>
'addTierPrice',
392 'modifierName' =>
'addSimpleProduct',
402 private function getBundleConfiguration6()
423 'type' =>
'checkbox',
441 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
446 'modifierName' =>
'addTierPrice',
450 'modifierName' =>
'addSimpleProduct',
460 private function getBundleConfiguration7()
481 'type' =>
'checkbox',
499 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
504 'modifierName' =>
'addTierPrice',
508 'modifierName' =>
'addSimpleProduct',
518 private function getBundleConfiguration8()
539 'type' =>
'checkbox',
557 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
562 'modifierName' =>
'addTierPrice',
566 'modifierName' =>
'addSimpleProduct',
576 private function getBundleConfiguration9()
600 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
603 $tierPriceSimpleProductData = [
611 'modifierName' =>
'addTierPrice',
615 'modifierName' =>
'addTierPriceForSimple',
616 'data' => [
'simple1', $tierPriceSimpleProductData]
619 'modifierName' =>
'addSimpleProduct',
632 $tierPrice = $this->tierPriceFactory->create([
633 'data' => $tirePriceData
635 $product->setTierPrices([$tierPrice]);
648 $simple = $this->productRepository->get($sku,
false,
null,
true);
650 $this->productRepository->save($simple);
prepareFixture($strategyModifiers, $productSku)
if($msrpShowOnGesture && $price['price']->getValue()< $product->getMsrp()) if($isSaleable) $tierPriceData
addTierPriceForSimple(\Magento\Catalog\Model\Product $bundleProduct, $sku, $tirePriceData)
addTierPrice(\Magento\Catalog\Model\Product $product, $tirePriceData)