Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertBundleProductPage.php
Go to the documentation of this file.
1 <?php
8 
10 
15 {
23  protected function verifyPrice()
24  {
25  $priceData = $this->product->getDataFieldConfig('price')['source']->getPriceData();
26  $priceView = $this->product->getPriceView();
27  $priceBlock = $this->productView->getPriceBlock();
28  if (!$priceBlock->isVisible()) {
29  return "Price block for '{$this->product->getName()}' product' is not visible.";
30  }
31 
32  if ($this->product->hasData('special_price')) {
33  $priceLow = $priceBlock->getPrice();
34  } else {
35  $priceLow = ($priceView == 'Price Range') ? $priceBlock->getPriceFrom() : $priceBlock->getPrice();
36  }
37 
38  $errors = [];
39 
40  if ($priceData['price_from'] != $priceLow) {
41  $errors[] = 'Bundle price "From" on product view page is not correct.';
42  }
43  if ($priceView == 'Price Range' && $priceData['price_to'] != $priceBlock->getPriceTo()) {
44  $errors[] = 'Bundle price "To" on product view page is not correct.';
45  }
46 
47  return empty($errors) ? null : implode("\n", $errors);
48  }
49 
55  protected function verifySpecialPrice()
56  {
57  if (!$this->product->hasData('special_price')) {
58  return null;
59  }
60 
61  $priceBlock = $this->productView->getPriceBlock();
62 
63  if (!$priceBlock->isVisible()) {
64  return "Price block for '{$this->product->getName()}' product' is not visible.";
65  }
66 
67  if (!$priceBlock->isOldPriceVisible()) {
68  return 'Bundle special price is not set.';
69  }
70 
71  $regularPrice = $priceBlock->getOldPrice();
72  $priceData = $this->product->getDataFieldConfig('price')['source']->getPriceData();
73 
74  if (!isset($priceData['regular_from'])) {
75  return 'Regular from price not set.';
76  }
77 
78  if ($priceData['regular_from'] != $regularPrice) {
79  return 'Bundle regular price on product view page is not correct.';
80  }
81 
82  return null;
83  }
84 }
$errors
Definition: overview.phtml:9