Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-grouped-product
Pricing
Price
ConfiguredRegularPrice.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\GroupedProduct\Pricing\Price
;
9
10
use
Magento\Catalog\Model\Product
;
11
use
Magento\Catalog\Model\Product\Configuration\Item\ItemInterface
;
12
use
Magento\Framework\Pricing\Price\AbstractPrice
;
13
use
Magento\Catalog\Pricing\Price\ConfiguredPriceInterface
;
14
18
class
ConfiguredRegularPrice
extends
AbstractPrice
implements
ConfiguredPriceInterface
19
{
23
const
PRICE_CODE
=
ConfiguredPriceInterface::CONFIGURED_REGULAR_PRICE_CODE
;
24
28
private
$item;
29
34
public
function
setItem
(
ItemInterface
$item):
ConfiguredRegularPrice
35
{
36
$this->item =
$item
;
37
38
return
$this;
39
}
40
46
protected
function
calculatePrice(): float
47
{
48
$value
= 0.;
50
$typeInstance
= $this->
getProduct
()->getTypeInstance();
51
$associatedProducts =
$typeInstance
52
->setStoreFilter($this->
getProduct
()->getStore(), $this->
getProduct
())
53
->getAssociatedProducts($this->
getProduct
());
54
55
foreach
($associatedProducts as
$product
) {
58
$customOption
= $this->
getProduct
()
59
->getCustomOption(
'associated_product_'
. $product->getId());
60
if
(!
$customOption
) {
61
continue
;
62
}
63
$finalPrice =
$product
->getPriceInfo()
64
->getPrice(\
Magento
\Catalog\Pricing\Price\RegularPrice::PRICE_CODE)
65
->getValue();
66
$value
+= $finalPrice * (
$customOption
->getValue() ?: 1);
67
}
68
69
return
$value
;
70
}
71
77
public
function
getValue
()
78
{
79
if
($this->item) {
80
return
$this->calculatePrice();
81
}
else
{
82
if
($this->
value
===
null
) {
83
$price
= $this->product->getPrice();
84
$priceInCurrentCurrency = $this->priceCurrency->convertAndRound(
$price
);
85
$this->
value
= $priceInCurrentCurrency ? (float)$priceInCurrentCurrency :
false
;
86
}
87
88
return
$this->value
;
89
}
90
}
91
}
Magento\GroupedProduct\Pricing\Price\ConfiguredRegularPrice\setItem
setItem(ItemInterface $item)
Definition:
ConfiguredRegularPrice.php:34
value
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition:
block.php:9
$customOption
$customOption
Definition:
products.php:73
Magento\Catalog\Model\Product\Configuration\Item\ItemInterface
Definition:
ItemInterface.php:15
$price
$price
Definition:
product_alert.php:10
$item
$item
Definition:
partial_invoice.php:27
Magento\GroupedProduct\Pricing\Price\ConfiguredRegularPrice\PRICE_CODE
const PRICE_CODE
Definition:
ConfiguredRegularPrice.php:23
Magento\Framework\Pricing\Price\AbstractPrice\getProduct
getProduct()
Definition:
AbstractPrice.php:136
Magento\Framework\Pricing\Price\AbstractPrice
Definition:
AbstractPrice.php:21
Magento\Framework\Pricing\Price\AbstractPrice\$value
$value
Definition:
AbstractPrice.php:61
Magento\Catalog\Pricing\Price\ConfiguredPriceInterface\CONFIGURED_REGULAR_PRICE_CODE
const CONFIGURED_REGULAR_PRICE_CODE
Definition:
ConfiguredPriceInterface.php:24
$typeInstance
$typeInstance
Definition:
order_item_with_bundle_and_options.php:27
Magento\Catalog\Pricing\Price\ConfiguredPriceInterface
Definition:
ConfiguredPriceInterface.php:14
Magento\Catalog\Model\Product
Definition:
ActionTest.php:6
Magento
Magento\GroupedProduct\Pricing\Price\ConfiguredRegularPrice\getValue
getValue()
Definition:
ConfiguredRegularPrice.php:77
Magento\Framework\Pricing\Price\AbstractPrice\$product
$product
Definition:
AbstractPrice.php:41
Magento\GroupedProduct\Pricing\Price
Definition:
FinalPriceTest.php:7
Magento\GroupedProduct\Pricing\Price\ConfiguredRegularPrice
Definition:
ConfiguredRegularPrice.php:18