I tried to override a model in Magento\Quote\Model\Cart\Data\CartItem but I cannot override it.
here is my di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Quote\Model\Cart\Data\CartItem" type="Vendor\AddProductWithVendorGraphQl\Model\Cart\Data\CartItem" />
</config>
and this is my class
class CartItem extends \Magento\Quote\Model\Cart\Data\CartItem
{
/**
* @var string
*/
private $sku;
/**
* @var float
*/
private $quantity;
/**
* @var string
*/
private $parentSku;
/**
* @var SelectedOption[]
*/
private $selectedOptions;
/**
* @var EnteredOption[]
*/
private $enteredOptions;
/**
* @param string $sku
* @param float $quantity
* @param string|null $parentSku
* @param array|null $selectedOptions
* @param array|null $enteredOptions
*/
public function __construct(
string $sku,
float $quantity,
string $parentSku = null,
array $selectedOptions = null,
array $enteredOptions = null
) {
$this->sku = $sku;
$this->quantity = $quantity;
$this->parentSku = $parentSku;
$this->selectedOptions = $selectedOptions;
$this->enteredOptions = $enteredOptions;
}
public function getQuantity(): float
{
var_dump('tes');die();
}
I've tried to use plugins too. But it still didn't work. Can anyone help me?