174 lines
3.9 KiB
PHP
174 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace Stemcell\Checkout\Model\Cart\Totals;
|
|
|
|
use Magento\Framework\Api\AttributeValueFactory;
|
|
use Stemcell\Checkout\Api\Data\Quote\TotalsItemInterface;
|
|
use \Magento\Quote\Model\Quote\ItemFactory as QuoteItemFactory;
|
|
use \Magento\Quote\Model\Quote\Item as QuoteItem;
|
|
use Stemcell\Customer\Api\Data\SalespersonInterface;
|
|
use Stemcell\Customer\Model\LabRepository;
|
|
|
|
class Item extends \Magento\Quote\Model\Cart\Totals\Item implements TotalsItemInterface
|
|
{
|
|
protected $item = null;
|
|
private SalespersonInterface $salespersonInterface;
|
|
private LabRepository $labRepository;
|
|
private QuoteItemFactory $itemFactory;
|
|
|
|
public function __construct(
|
|
\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
|
|
\Magento\Framework\Api\AttributeValueFactory $attributeValueFactory,
|
|
QuoteItemFactory $itemFactory,
|
|
SalespersonInterface $salespersonInterface,
|
|
LabRepository $labRepository,
|
|
$data = []
|
|
) {
|
|
$this->itemFactory = $itemFactory;
|
|
$this->salespersonInterface = $salespersonInterface;
|
|
$this->labRepository = $labRepository;
|
|
parent::__construct($extensionFactory, $attributeValueFactory, $data);
|
|
}
|
|
|
|
/**
|
|
* @return QuoteItem
|
|
*/
|
|
protected function getQuoteItem()
|
|
{
|
|
if (!$this->item) {
|
|
$this->item = $this->itemFactory->create()->load($this->getItemId());
|
|
}
|
|
return $this->item;
|
|
}
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getSku()
|
|
{
|
|
return $this->_get(self::SKU);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function setSku(string $sku)
|
|
{
|
|
return $this->setData(self::SKU, $this->getQuoteItem()->getSku());
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getSalespersonName()
|
|
{
|
|
return $this->_get(self::SALESPERSON_NAME);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function setSalespersonName(string | null $salespersonName)
|
|
{
|
|
|
|
return $this->setData(self::SALESPERSON_NAME, $salespersonName);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getLabBookingAccount()
|
|
{
|
|
return $this->_get(self::LAB_BOOKING_ACCOUNT);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function setLabBookingAccount(string $labBookingAccount)
|
|
{
|
|
return $this->setData(self::LAB_BOOKING_ACCOUNT, $labBookingAccount);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getCdCode()
|
|
{
|
|
return $this->_get(self::CD_CODE);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function setCdCode(string $cdCode)
|
|
{
|
|
return $this->setData(self::CD_CODE, $this->getQuoteItem()->getCd());
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getQuoteCode()
|
|
{
|
|
|
|
return $this->_get(self::QUOTE_CODE);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function setQuoteCode(string $quoteCode)
|
|
{
|
|
return $this->setData(self::QUOTE_CODE, $this->getQuoteItem()->getData('quote'));
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getPiSapId()
|
|
{
|
|
return $this->_get(self::PI_SAP_ID);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function setPiSapId(string $piSapId)
|
|
{
|
|
return $this->setData(self::PI_SAP_ID, $this->getQuoteItem()->getData(self::PI_SAP_ID));
|
|
}
|
|
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getCustomerDiscountPercent()
|
|
{
|
|
return $this->_get(self::CUSTOMER_DISCOUNT_PERCENT);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function setCustomerDiscountPercent(string $customerDiscountPercent)
|
|
{
|
|
return $this->setData(self::CUSTOMER_DISCOUNT_PERCENT, $customerDiscountPercent);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getNote()
|
|
{
|
|
return $this->_get(self::NOTE);
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function setNote(string $note)
|
|
{
|
|
return $this->setData(self::NOTE, $note);
|
|
}
|
|
}
|