Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractPriceBlock.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Block\Block;
10 use Magento\Mtf\Client\Locator;
11 use Magento\Mtf\Client\Element\SimpleElement;
12 
16 abstract class AbstractPriceBlock extends Block
17 {
23  protected $mapTypePrices = [];
24 
32  protected function getTypePrice($type, $currency = '$')
33  {
34  $typePriceElement = $this->getTypePriceElement($type);
35  return $typePriceElement->isVisible() ? $this->trimPrice($typePriceElement->getText(), $currency) : null;
36  }
37 
44  protected function getTypePriceElement($type)
45  {
46  $mapTypePrice = $this->mapTypePrices[$type];
47  return $this->_rootElement->find(
48  $mapTypePrice['selector'],
49  isset($mapTypePrice['strategy']) ? $mapTypePrice['strategy'] : Locator::SELECTOR_CSS
50  );
51  }
52 
60  protected function trimPrice($price, $currency = '$')
61  {
62  return str_replace([',', $currency], '', $price);
63  }
64 }
$price
$type
Definition: item.phtml:13