Files
stemcell/app/code/Stemcell/Checkout/Block/Cart/Item/Renderer/Configurable.php
T
2026-09-15 10:26:34 +08:00

81 lines
2.1 KiB
PHP

<?php
namespace Stemcell\Checkout\Block\Cart\Item\Renderer;
use Stemcell\Checkout\Block\Cart\Item\Renderer;
use Magento\Framework\DataObject\IdentityInterface;
class Configurable extends Renderer implements IdentityInterface
{
/**
* Path in config to the setting which defines if parent or child product should be used to generate a thumbnail.
* @deprecated moved to model because of class refactoring
* @see \Magento\ConfigurableProduct\Model\Product\Configuration\Item\ItemProductResolver::CONFIG_THUMBNAIL_SOURCE
*/
const CONFIG_THUMBNAIL_SOURCE = 'checkout/cart/configurable_product_image';
/**
* Get item configurable child product
*
* @return \Magento\Catalog\Model\Product|null
*/
public function getChildProduct()
{
if ($option = $this->getItem()->getOptionByCode('simple_product')) {
return $option->getProduct();
}
return $this->getProduct();
}
/**
* Get item product name
*
* @return string
*/
public function getProductName()
{
if ($option = $this->getItem()->getOptionByCode('simple_product')) {
return $option->getProduct()->getName();
}
return $this->getProduct()->getName();
}
/**
* Get list of all options for product
*
* @return array
*/
public function getOptionList()
{
return $this->_productConfig->getOptions($this->getItem());
}
/**
* Return identifiers for produced content
*
* @return array
*/
public function getIdentities()
{
$identities = parent::getIdentities();
if ($this->getItem()) {
$identities = array_merge($identities, $this->getChildProduct()->getIdentities());
}
return $identities;
}
/**
* Get price for exact simple product added to cart
*
* @inheritdoc
* @since 100.3.1
*/
public function getProductPriceHtml(\Magento\Catalog\Model\Product $product)
{
return parent::getProductPriceHtml($this->getChildProduct());
}
}
{
}