9 use \Magento\Bundle\Api\Data\LinkInterface;
10 use \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
20 private $tierPriceFactory;
25 $this->tierPriceFactory = $this->objectManager->create(ProductTierPriceInterfaceFactory::class);
36 public function testPriceForFixedBundle(array $strategyModifiers, array $expectedResults)
39 $bundleProduct = $this->productRepository->get(
'bundle_product',
false,
null,
true);
42 $this->markTestSkipped(
'Unskip after fixing https://github.com/magento-engcom/msi/issues/1398');
50 $expectedResults[
'minimalPrice'],
51 $priceInfo->getPrice($priceCode)->getMinimalPrice()->getValue(),
52 'Failed to check minimal price on product' 55 $expectedResults[
'maximalPrice'],
56 $priceInfo->getPrice($priceCode)->getMaximalPrice()->getValue(),
57 'Failed to check maximal price on product' 60 $priceInfoFromIndexer = $this->productCollectionFactory->create()
61 ->addFieldToFilter(
'sku',
'bundle_product')
66 $this->assertEquals($expectedResults[
'minimalPrice'], $priceInfoFromIndexer->getMinimalPrice());
67 $this->assertEquals($expectedResults[
'maximalPrice'], $priceInfoFromIndexer->getMaxPrice());
79 #1 Testing product price 80 with tier price and without any sub items and options 82 'strategy' => $this->getBundleConfiguration1(),
83 'expectedResults' => [
93 #2 Testing product price 94 with tier price, fixed sub items and fixed options 96 'strategy' => $this->getProductConfiguration2(
98 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
100 'expectedResults' => [
102 'minimalPrice' => 165,
105 'maximalPrice' => 165,
110 #3 Testing product price 111 with tier price, percent sub items and percent options 113 'strategy' => $this->getProductConfiguration2(
115 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
117 'expectedResults' => [
119 'minimalPrice' => 121,
122 'maximalPrice' => 121,
127 #4 Testing product price 128 with tier price, fixed sub items and percent options 130 'strategy' => $this->getProductConfiguration2(
132 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
134 'expectedResults' => [
136 'minimalPrice' => 120,
139 'maximalPrice' => 120,
144 #5 Testing product price 145 with tier price, percent sub items and fixed options 147 'strategy' => $this->getProductConfiguration2(
149 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
151 'expectedResults' => [
153 'minimalPrice' => 166,
156 'maximalPrice' => 166,
161 #6 Testing product price 162 with tier price, fixed sub items and fixed options 164 'strategy' => $this->getProductConfiguration3(
166 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
168 'expectedResults' => [
170 'minimalPrice' => 155,
173 'maximalPrice' => 175,
178 #7 Testing product price 179 with tier price, percent sub items and percent options 181 'strategy' => $this->getProductConfiguration3(
183 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
185 'expectedResults' => [
187 'minimalPrice' => 110,
190 'maximalPrice' => 132,
195 #8 Testing product price 196 with tier price, fixed sub items and percent options 198 'strategy' => $this->getProductConfiguration3(
200 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
202 'expectedResults' => [
204 'minimalPrice' => 110,
207 'maximalPrice' => 130,
213 #9 Testing product price 214 with tier price, percent sub items and fixed options 216 'strategy' => $this->getProductConfiguration3(
218 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
220 'expectedResults' => [
222 'minimalPrice' => 155,
225 'maximalPrice' => 177,
230 #10 Testing product price 231 with tier price, fixed sub items and fixed options 233 'strategy' => $this->getProductConfiguration4(
235 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
237 'expectedResults' => [
239 'minimalPrice' => 170,
242 'maximalPrice' => 190,
247 #11 Testing product price 248 with tier price, percent sub items and percent options 250 'strategy' => $this->getProductConfiguration4(
252 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
254 'expectedResults' => [
256 'minimalPrice' => 126.5,
259 'maximalPrice' => 148.5,
264 #12 Testing product price 265 with tier price, fixed sub items and percent options 267 'strategy' => $this->getProductConfiguration4(
269 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
271 'expectedResults' => [
273 'minimalPrice' => 125,
276 'maximalPrice' => 145,
281 #13 Testing product price 282 with tier price, percent sub items and fixed options 284 'strategy' => $this->getProductConfiguration4(
286 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
288 'expectedResults' => [
290 'minimalPrice' => 171.5,
293 'maximalPrice' => 193.5,
298 #14 Testing product price 299 with tier price, fixed sub items and fixed options 301 'strategy' => $this->getProductConfiguration5(
303 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
305 'expectedResults' => [
307 'minimalPrice' => 175,
310 'maximalPrice' => 197.5,
315 #15 Testing product price 316 with tier price, percent sub items and percent options 318 'strategy' => $this->getProductConfiguration5(
320 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
322 'expectedResults' => [
324 'minimalPrice' => 132,
327 'maximalPrice' => 156.75,
332 #16 Testing product price 333 with tier price, fixed sub items and percent options 335 'strategy' => $this->getProductConfiguration5(
337 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
339 'expectedResults' => [
341 'minimalPrice' => 130,
344 'maximalPrice' => 152.5,
349 #17 Testing product price 350 with tier price, percent sub items and fixed options 352 'strategy' => $this->getProductConfiguration5(
354 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
356 'expectedResults' => [
358 'minimalPrice' => 177,
361 'maximalPrice' => 201.75,
366 #18 Testing product price 367 with tier price, fixed sub items and fixed options 369 'strategy' => $this->getProductConfiguration6(
371 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
373 'expectedResults' => [
375 'minimalPrice' => 175,
378 'maximalPrice' => 177.5,
383 #19 Testing product price 384 with tier price, percent sub items and percent options 386 'strategy' => $this->getProductConfiguration6(
388 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
390 'expectedResults' => [
392 'minimalPrice' => 132,
395 'maximalPrice' => 134.75,
400 #20 Testing product price 401 with tier price, fixed sub items and percent options 403 'strategy' => $this->getProductConfiguration6(
405 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
407 'expectedResults' => [
409 'minimalPrice' => 130,
412 'maximalPrice' => 132.5,
417 #21 Testing product price 418 with tier price, percent sub items and fixed options 420 'strategy' => $this->getProductConfiguration6(
422 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
424 'expectedResults' => [
426 'minimalPrice' => 177,
429 'maximalPrice' => 179.75,
434 #22 Testing product price 435 with tier price, fixed sub items and fixed options 437 'strategy' => $this->getProductConfiguration7(
439 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
441 'expectedResults' => [
443 'minimalPrice' => 185,
446 'maximalPrice' => 202.5,
451 #23 Testing product price 452 with tier price, percent sub items and percent options 454 'strategy' => $this->getProductConfiguration7(
456 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
458 'expectedResults' => [
460 'minimalPrice' => 143,
463 'maximalPrice' => 162.25,
468 #24 Testing product price 469 with tier price, fixed sub items and percent options 471 'strategy' => $this->getProductConfiguration7(
473 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
475 'expectedResults' => [
477 'minimalPrice' => 140,
480 'maximalPrice' => 157.5,
485 #25 Testing product price 486 with tier price, percent sub items and fixed options 488 'strategy' => $this->getProductConfiguration7(
490 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
492 'expectedResults' => [
494 'minimalPrice' => 188,
497 'maximalPrice' => 207.25,
507 private function getBundleConfiguration1()
513 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
518 'modifierName' =>
'addTierPrice',
530 private function getProductConfiguration2($selectionsPriceType, $customOptionsPriceType)
536 'type' =>
'checkbox',
542 'price_type' => $selectionsPriceType
548 $customOptionsData = [
550 'price_type' => $customOptionsPriceType,
551 'title' =>
'Test Field',
563 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
568 'modifierName' =>
'addTierPrice',
572 'modifierName' =>
'addSimpleProduct',
576 'modifierName' =>
'addCustomOption',
577 'data' => [$customOptionsData]
588 private function getProductConfiguration3($selectionsPriceType, $customOptionsPriceType)
593 'type' =>
'checkbox',
600 'price_type' => $selectionsPriceType
606 $customOptionsData = [
608 'price_type' => $customOptionsPriceType,
609 'title' =>
'Test Field',
621 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
626 'modifierName' =>
'addTierPrice',
630 'modifierName' =>
'addSimpleProduct',
634 'modifierName' =>
'addCustomOption',
635 'data' => [$customOptionsData]
646 private function getProductConfiguration4($selectionsPriceType, $customOptionsPriceType)
652 'type' =>
'checkbox',
658 'price_type' => $selectionsPriceType
664 'price_type' => $selectionsPriceType
670 $customOptionsData = [
672 'price_type' => $customOptionsPriceType,
673 'title' =>
'Test Field',
685 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
690 'modifierName' =>
'addTierPrice',
694 'modifierName' =>
'addSimpleProduct',
698 'modifierName' =>
'addCustomOption',
699 'data' => [$customOptionsData]
710 private function getProductConfiguration5($selectionsPriceType, $customOptionsPriceType)
722 'price_type' => $selectionsPriceType
728 'price_type' => $selectionsPriceType
734 $customOptionsData = [
736 'price_type' => $customOptionsPriceType,
737 'title' =>
'Test Field',
749 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
754 'modifierName' =>
'addTierPrice',
758 'modifierName' =>
'addSimpleProduct',
762 'modifierName' =>
'addCustomOption',
763 'data' => [$customOptionsData]
774 private function getProductConfiguration6($selectionsPriceType, $customOptionsPriceType)
786 'price_type' => $selectionsPriceType
792 'price_type' => $selectionsPriceType
798 $customOptionsData = [
800 'price_type' => $customOptionsPriceType,
801 'title' =>
'Test Field',
813 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
818 'modifierName' =>
'addTierPrice',
822 'modifierName' =>
'addSimpleProduct',
826 'modifierName' =>
'addCustomOption',
827 'data' => [$customOptionsData]
838 private function getProductConfiguration7($selectionsPriceType, $customOptionsPriceType)
850 'price_type' => $selectionsPriceType
856 'price_type' => $selectionsPriceType
863 'type' =>
'checkbox',
869 'price_type' => $selectionsPriceType
875 'price_type' => $selectionsPriceType
881 $customOptionsData = [
883 'price_type' => $customOptionsPriceType,
884 'title' =>
'Test Field',
896 'extension_attributes' => new \Magento\Framework\DataObject([
'percentage_value' => 50])
901 'modifierName' =>
'addTierPrice',
905 'modifierName' =>
'addSimpleProduct',
909 'modifierName' =>
'addCustomOption',
910 'data' => [$customOptionsData]
922 $tierPrice = $this->tierPriceFactory->create([
923 'data' => $tirePriceData
925 $product->setTierPrices([$tierPrice]);
prepareFixture($strategyModifiers, $productSku)
if($msrpShowOnGesture && $price['price']->getValue()< $product->getMsrp()) if($isSaleable) $tierPriceData
addTierPrice(\Magento\Catalog\Model\Product $product, $tirePriceData)