|
| | __construct (\Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\GiftMessage\Model\MessageFactory $messageFactory, \Magento\Backend\Model\Session\Quote $session, \Magento\GiftMessage\Helper\Message $giftMessageMessage) |
| |
| | saveAllInQuote () |
| |
| | getSaved () |
| |
| | saveAllInOrder () |
| |
| | setAllowQuoteItems ($items) |
| |
| | addAllowQuoteItem ($item) |
| |
| | getAllowQuoteItems () |
| |
| | getAllowQuoteItemsProducts () |
| |
| | getIsAllowedQuoteItem ($item) |
| |
| | isGiftMessagesAvailable ($item) |
| |
| | importAllowQuoteItemsFromProducts ($products) |
| |
| | importAllowQuoteItemsFromItems ($items) |
| |
| | __construct (array $data=[]) |
| |
| | addData (array $arr) |
| |
| | setData ($key, $value=null) |
| |
| | unsetData ($key=null) |
| |
| | getData ($key='', $index=null) |
| |
| | getDataByPath ($path) |
| |
| | getDataByKey ($key) |
| |
| | setDataUsingMethod ($key, $args=[]) |
| |
| | getDataUsingMethod ($key, $args=null) |
| |
| | hasData ($key='') |
| |
| | toArray (array $keys=[]) |
| |
| | convertToArray (array $keys=[]) |
| |
| | toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true) |
| |
| | convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true) |
| |
| | toJson (array $keys=[]) |
| |
| | convertToJson (array $keys=[]) |
| |
| | toString ($format='') |
| |
| | __call ($method, $args) |
| |
| | isEmpty () |
| |
| | serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"') |
| |
| | debug ($data=null, &$objects=[]) |
| |
| | offsetSet ($offset, $value) |
| |
| | offsetExists ($offset) |
| |
| | offsetUnset ($offset) |
| |
| | offsetGet ($offset) |
| |
◆ __construct()
- Parameters
-
| \Magento\Catalog\Api\ProductRepositoryInterface | $productRepository | |
| \Magento\GiftMessage\Model\MessageFactory | $messageFactory | |
| \Magento\Backend\Model\Session\Quote | $session | |
| \Magento\GiftMessage\Helper\Message | $giftMessageMessage | |
Definition at line 48 of file Save.php.
57 $this->_giftMessageMessage = $giftMessageMessage;
◆ _deleteOne()
| _deleteOne |
( |
|
$entityModel, |
|
|
|
$giftmessageModel = null |
|
) |
| |
|
protected |
Delete a single gift message from entity
- Parameters
-
| \Magento\Framework\DataObject | $entityModel | |
| \Magento\GiftMessage\Model\Message | null | $giftmessageModel | |
- Returns
- $this
Definition at line 170 of file Save.php.
172 if ($giftmessageModel ===
null) {
173 $giftmessageModel = $this->_messageFactory->create()->load(
$entityModel->getGiftMessageId());
175 $giftmessageModel->delete();
◆ _getQuote()
Retrieve quote object
- Returns
- \Magento\Quote\Model\Quote @codeCoverageIgnore
Definition at line 359 of file Save.php.
361 return $this->_session->getQuote();
◆ _saveOne()
| _saveOne |
( |
|
$entityId, |
|
|
|
$giftmessage, |
|
|
|
$entityType |
|
) |
| |
|
protected |
Save a single gift message
- Parameters
-
| int | $entityId | |
| array | $giftmessage | |
| string | $entityType | |
- Returns
- $this
Definition at line 118 of file Save.php.
121 $giftmessageModel = $this->_messageFactory->create();
142 $giftmessageModel->load(
$entityModel->getGiftMessageId());
145 $giftmessageModel->addData($giftmessage);
147 if ($giftmessageModel->isMessageEmpty() && $giftmessageModel->getId()) {
150 $this->_saved =
false;
151 }
elseif (!$giftmessageModel->isMessageEmpty()) {
152 $giftmessageModel->save();
153 $entityModel->setGiftMessageId($giftmessageModel->getId());
157 $this->_saved =
true;
elseif(isset( $params[ 'redirect_parent']))
_deleteOne($entityModel, $giftmessageModel=null)
◆ addAllowQuoteItem()
| addAllowQuoteItem |
( |
|
$item | ) |
|
Add allowed quote item for gift messages
- Parameters
-
- Returns
- $this
Definition at line 198 of file Save.php.
setAllowQuoteItems($items)
◆ getAllowQuoteItems()
Retrieve allowed quote items for gift messages
- Returns
- array
Definition at line 214 of file Save.php.
216 if (!is_array($this->_session->getAllowQuoteItemsGiftMessage())) {
220 return $this->_session->getAllowQuoteItemsGiftMessage();
setAllowQuoteItems($items)
◆ getAllowQuoteItemsProducts()
| getAllowQuoteItemsProducts |
( |
| ) |
|
Retrieve allowed quote items products for gift messages
- Returns
- array
Definition at line 228 of file Save.php.
◆ getIsAllowedQuoteItem()
| getIsAllowedQuoteItem |
( |
|
$item | ) |
|
Checks allowed quote item for gift messages
- Parameters
-
| \Magento\Framework\DataObject | $item | |
- Returns
- bool @SuppressWarnings(PHPMD.BooleanGetMethodName)
Definition at line 248 of file Save.php.
isGiftMessagesAvailable($item)
◆ getMappedType()
Retrieve mapped type for entity
- Parameters
-
- Returns
- string|null
Definition at line 338 of file Save.php.
342 'item' =>
'quote_item',
344 'order_item' =>
'order_item',
◆ getSaved()
- Returns
- bool @SuppressWarnings(PHPMD.BooleanGetMethodName) @codeCoverageIgnore
Definition at line 86 of file Save.php.
◆ importAllowQuoteItemsFromItems()
| importAllowQuoteItemsFromItems |
( |
|
$items | ) |
|
- Parameters
-
- Returns
- $this
Definition at line 307 of file Save.php.
310 $deleteAllowedItems = [];
316 $deleteAllowedItems[] = $itemId;
320 if (in_array(
$item->getId(), $allowedItems) && !isset(
$data[
'giftmessage'])) {
321 $deleteAllowedItems[] =
$item->getId();
322 }
elseif (!in_array(
$item->getId(), $allowedItems) && isset(
$data[
'giftmessage'])) {
323 $allowedItems[] =
$item->getId();
327 $allowedItems = array_diff($allowedItems, $deleteAllowedItems);
elseif(isset( $params[ 'redirect_parent']))
setAllowQuoteItems($items)
◆ importAllowQuoteItemsFromProducts()
| importAllowQuoteItemsFromProducts |
( |
|
$products | ) |
|
Imports quote items for gift messages from products data
- Parameters
-
- Returns
- $this
Definition at line 278 of file Save.php.
281 $deleteAllowedItems = [];
283 $product = $this->productRepository->getById(
$productId,
false, $this->_session->getStore()->getId());
290 if (in_array(
$item->getId(), $allowedItems) && !isset(
$data[
'giftmessage'])) {
291 $deleteAllowedItems[] =
$item->getId();
292 }
elseif (!in_array(
$item->getId(), $allowedItems) && isset(
$data[
'giftmessage'])) {
293 $allowedItems[] =
$item->getId();
297 $allowedItems = array_diff($allowedItems, $deleteAllowedItems);
elseif(isset( $params[ 'redirect_parent']))
setAllowQuoteItems($items)
◆ isGiftMessagesAvailable()
| isGiftMessagesAvailable |
( |
|
$item | ) |
|
Retrieve is gift message available for item (product)
- Parameters
-
| \Magento\Framework\DataObject | $item | |
- Returns
- bool
Definition at line 267 of file Save.php.
269 return $this->_giftMessageMessage->isMessagesAllowed(
'item',
$item,
$item->getStore());
◆ saveAllInOrder()
- Returns
- $this
Definition at line 94 of file Save.php.
96 $giftMessages = $this->getGiftmessages();
98 if (!is_array($giftMessages)) {
_saveOne($entityId, $giftmessage, $entityType)
◆ saveAllInQuote()
Save all seted giftmessages
- Returns
- $this
Definition at line 65 of file Save.php.
67 $giftmessages = $this->getGiftmessages();
69 if (!is_array($giftmessages)) {
73 foreach ($giftmessages as $entityId => $giftmessage) {
_saveOne($entityId, $giftmessage, $entityType)
◆ setAllowQuoteItems()
| setAllowQuoteItems |
( |
|
$items | ) |
|
Set allowed quote items for gift messages
- Parameters
-
- Returns
- $this
Definition at line 186 of file Save.php.
188 $this->_session->setAllowQuoteItemsGiftMessage(
$items);
◆ $_giftMessageMessage
| $_giftMessageMessage = null |
|
protected |
◆ $_messageFactory
◆ $_saved
◆ $_session
◆ $productRepository
The documentation for this class was generated from the following file:
- vendor/magento/module-gift-message/Model/Save.php