Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Wishlist Class Reference
Inheritance diagram for Wishlist:
AbstractModel IdentityInterface DataObject

Public Member Functions

 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Wishlist\Helper\Data $wishlistData, ResourceWishlist $resource, Collection $resourceCollection, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, ItemFactory $wishlistItemFactory, CollectionFactory $wishlistCollectionFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Stdlib\DateTime $dateTime, ProductRepositoryInterface $productRepository, $useCurrentWebsite=true, array $data=[], Json $serializer=null)
 
 loadByCustomerId ($customerId, $create=false)
 
 getName ()
 
 generateSharingCode ()
 
 loadByCode ($code)
 
 beforeSave ()
 
 afterSave ()
 
 getItemCollection ()
 
 getItem ($itemId)
 
 addItem (Item $item)
 
 addNewItem ($product, $buyRequest=null, $forciblySetQty=false)
 
 setCustomerId ($customerId)
 
 getCustomerId ()
 
 getDataForSave ()
 
 getSharedStoreIds ()
 
 setSharedStoreIds ($storeIds)
 
 getStore ()
 
 setStore ($store)
 
 getItemsCount ()
 
 isSalable ()
 
 isOwner ($customerId)
 
 updateItem ($itemId, $buyRequest, $params=null)
 
 getIdentities ()
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 __sleep ()
 
 __wakeup ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 setDataChanges ($value)
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($modelId, $field=null)
 
 beforeLoad ($identifier, $field=null)
 
 afterLoad ()
 
 isSaveAllowed ()
 
 setHasDataChanges ($flag)
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 beforeSave ()
 
 validateBeforeSave ()
 
 getCacheTags ()
 
 cleanModelCache ()
 
 afterSave ()
 
 delete ()
 
 beforeDelete ()
 
 afterDelete ()
 
 afterDeleteCommit ()
 
 getResource ()
 
 getEntityId ()
 
 setEntityId ($entityId)
 
 clearInstance ()
 
 getStoredData ()
 
 getEventPrefix ()
 
- Public Member Functions inherited from DataObject
 __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)
 

Data Fields

const CACHE_TAG = 'wishlist'
 

Protected Member Functions

 _getSharingRandomCode ()
 
 _addCatalogProduct (\Magento\Catalog\Model\Product $product, $qty=1, $forciblySetQty=false)
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_eventPrefix = 'wishlist'
 
 $_itemCollection
 
 $_store
 
 $_storeIds
 
 $_wishlistData
 
 $_catalogProduct
 
 $_storeManager
 
 $_date
 
 $_wishlistItemFactory
 
 $_wishlistCollectionFactory
 
 $_productFactory
 
 $mathRandom
 
 $dateTime
 
 $_useCurrentWebsite
 
 $productRepository
 
- Protected Attributes inherited from AbstractModel
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_idFieldName = 'id'
 
 $_hasDataChanges = false
 
 $_origData
 
 $_isDeleted = false
 
 $_resource
 
 $_resourceCollection
 
 $_resourceName
 
 $_collectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
 $_validatorBeforeSave = null
 
 $_eventManager
 
 $_cacheManager
 
 $_registry
 
 $_logger
 
 $_appState
 
 $_actionValidator
 
 $storedData = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Wishlist model

@method int getShared() @method \Magento\Wishlist\Model\Wishlist setShared(int $value) @method string getSharingCode() @method \Magento\Wishlist\Model\Wishlist setSharingCode(string $value) @method string getUpdatedAt() @method \Magento\Wishlist\Model\Wishlist setUpdatedAt(string $value) @SuppressWarnings(PHPMD.CouplingBetweenObjects) @SuppressWarnings(PHPMD.TooManyFields)

@api

Since
100.0.2

Definition at line 33 of file Wishlist.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Model\Context  $context,
\Magento\Framework\Registry  $registry,
\Magento\Catalog\Helper\Product  $catalogProduct,
\Magento\Wishlist\Helper\Data  $wishlistData,
ResourceWishlist  $resource,
Collection  $resourceCollection,
\Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Framework\Stdlib\DateTime\DateTime  $date,
ItemFactory  $wishlistItemFactory,
CollectionFactory  $wishlistCollectionFactory,
\Magento\Catalog\Model\ProductFactory  $productFactory,
\Magento\Framework\Math\Random  $mathRandom,
\Magento\Framework\Stdlib\DateTime  $dateTime,
ProductRepositoryInterface  $productRepository,
  $useCurrentWebsite = true,
array  $data = [],
Json  $serializer = null 
)

Constructor

Parameters
\Magento\Framework\Model\Context$context
\Magento\Framework\Registry$registry
\Magento\Catalog\Helper\Product$catalogProduct
\Magento\Wishlist\Helper\Data$wishlistData
ResourceWishlist$resource
Collection$resourceCollection
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Framework\Stdlib\DateTime\DateTime$date
ItemFactory$wishlistItemFactory
CollectionFactory$wishlistCollectionFactory
\Magento\Catalog\Model\ProductFactory$productFactory
\Magento\Framework\Math\Random$mathRandom
\Magento\Framework\Stdlib\DateTime$dateTime
ProductRepositoryInterface$productRepository
bool$useCurrentWebsite
array$data
Json | null$serializer@SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 154 of file Wishlist.php.

172  {
173  $this->_useCurrentWebsite = $useCurrentWebsite;
174  $this->_catalogProduct = $catalogProduct;
175  $this->_wishlistData = $wishlistData;
176  $this->_storeManager = $storeManager;
177  $this->_date = $date;
178  $this->_wishlistItemFactory = $wishlistItemFactory;
179  $this->_wishlistCollectionFactory = $wishlistCollectionFactory;
180  $this->_productFactory = $productFactory;
181  $this->mathRandom = $mathRandom;
182  $this->dateTime = $dateTime;
183  $this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
184  parent::__construct($context, $registry, $resource, $resourceCollection, $data);
185  $this->productRepository = $productRepository;
186  }
$storeManager
$resource
Definition: bulk.php:12

Member Function Documentation

◆ _addCatalogProduct()

_addCatalogProduct ( \Magento\Catalog\Model\Product  $product,
  $qty = 1,
  $forciblySetQty = false 
)
protected

Add catalog product object data to wishlist

Parameters
\Magento\Catalog\Model\Product$product
int$qty
bool$forciblySetQty
Returns
Item

Definition at line 299 of file Wishlist.php.

300  {
301  $item = null;
302  foreach ($this->getItemCollection() as $_item) {
303  if ($_item->representProduct($product)) {
304  $item = $_item;
305  break;
306  }
307  }
308 
309  if ($item === null) {
310  $storeId = $product->hasWishlistStoreId() ? $product->getWishlistStoreId() : $this->getStore()->getId();
311  $item = $this->_wishlistItemFactory->create();
312  $item->setProductId($product->getId());
313  $item->setWishlistId($this->getId());
314  $item->setAddedAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
315  $item->setStoreId($storeId);
316  $item->setOptions($product->getCustomOptions());
317  $item->setProduct($product);
318  $item->setQty($qty);
319  $item->save();
320  if ($item->getId()) {
321  $this->getItemCollection()->addItem($item);
322  }
323  } else {
324  $qty = $forciblySetQty ? $qty : $item->getQty() + $qty;
325  $item->setQty($qty)->save();
326  }
327 
328  $this->addItem($item);
329 
330  return $item;
331  }
$_item
Definition: default.phtml:11

◆ _getSharingRandomCode()

_getSharingRandomCode ( )
protected

Retrieve sharing code (random string)

Returns
string

Definition at line 258 of file Wishlist.php.

259  {
260  return $this->mathRandom->getUniqueHash();
261  }

◆ addItem()

addItem ( Item  $item)

Adding item to wishlist

Parameters
Item$item
Returns
$this

Definition at line 371 of file Wishlist.php.

372  {
373  $item->setWishlist($this);
374  if (!$item->getId()) {
375  $this->getItemCollection()->addItem($item);
376  $this->_eventManager->dispatch('wishlist_add_item', ['item' => $item]);
377  }
378  return $this;
379  }

◆ addNewItem()

addNewItem (   $product,
  $buyRequest = null,
  $forciblySetQty = false 
)

Adds new product to wishlist.

Returns new item or string on error.

Parameters
int | \Magento\Catalog\Model\Product$product
\Magento\Framework\DataObject | array | string | null$buyRequest
bool$forciblySetQty
Exceptions

Error message

If prepare process return one object

Definition at line 394 of file Wishlist.php.

395  {
396  /*
397  * Always load product, to ensure:
398  * a) we have new instance and do not interfere with other products in wishlist
399  * b) product has full set of attributes
400  */
401  if ($product instanceof \Magento\Catalog\Model\Product) {
402  $productId = $product->getId();
403  // Maybe force some store by wishlist internal properties
404  $storeId = $product->hasWishlistStoreId() ? $product->getWishlistStoreId() : $product->getStoreId();
405  } else {
406  $productId = (int)$product;
407  if (isset($buyRequest) && $buyRequest->getStoreId()) {
408  $storeId = $buyRequest->getStoreId();
409  } else {
410  $storeId = $this->_storeManager->getStore()->getId();
411  }
412  }
413 
414  try {
415  $product = $this->productRepository->getById($productId, false, $storeId);
416  } catch (NoSuchEntityException $e) {
417  throw new \Magento\Framework\Exception\LocalizedException(__('Cannot specify product.'));
418  }
419 
420  if ($buyRequest instanceof \Magento\Framework\DataObject) {
421  $_buyRequest = $buyRequest;
422  } elseif (is_string($buyRequest)) {
423  $isInvalidItemConfiguration = false;
424  try {
425  $buyRequestData = $this->serializer->unserialize($buyRequest);
426  if (!is_array($buyRequestData)) {
427  $isInvalidItemConfiguration = true;
428  }
429  } catch (\InvalidArgumentException $exception) {
430  $isInvalidItemConfiguration = true;
431  }
432  if ($isInvalidItemConfiguration) {
433  throw new \InvalidArgumentException('Invalid wishlist item configuration.');
434  }
435  $_buyRequest = new \Magento\Framework\DataObject($buyRequestData);
436  } elseif (is_array($buyRequest)) {
437  $_buyRequest = new \Magento\Framework\DataObject($buyRequest);
438  } else {
439  $_buyRequest = new \Magento\Framework\DataObject();
440  }
441 
442  /* @var $product \Magento\Catalog\Model\Product */
443  $cartCandidates = $product->getTypeInstance()->processConfiguration($_buyRequest, clone $product);
444 
448  if (is_string($cartCandidates)) {
449  return $cartCandidates;
450  }
451 
455  if (!is_array($cartCandidates)) {
456  $cartCandidates = [$cartCandidates];
457  }
458 
459  $errors = [];
460  $items = [];
461 
462  foreach ($cartCandidates as $candidate) {
463  if ($candidate->getParentProductId()) {
464  continue;
465  }
466  $candidate->setWishlistStoreId($storeId);
467 
468  $qty = $candidate->getQty() ? $candidate->getQty() : 1;
469  // No null values as qty. Convert zero to 1.
470  $item = $this->_addCatalogProduct($candidate, $qty, $forciblySetQty);
471  $items[] = $item;
472 
473  // Collect errors instead of throwing first one
474  if ($item->getHasError()) {
475  $errors[] = $item->getMessage();
476  }
477  }
478 
479  $this->_eventManager->dispatch('wishlist_product_add_after', ['items' => $items]);
480 
481  return $item;
482  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
__()
Definition: __.php:13
foreach($product->getExtensionAttributes() ->getBundleProductOptions() as $option) $buyRequest
_addCatalogProduct(\Magento\Catalog\Model\Product $product, $qty=1, $forciblySetQty=false)
Definition: Wishlist.php:299
$errors
Definition: overview.phtml:9
$items

◆ afterSave()

afterSave ( )

Save related items

Returns
$this

Definition at line 280 of file Wishlist.php.

281  {
282  parent::afterSave();
283 
284  if (null !== $this->_itemCollection) {
285  $this->getItemCollection()->save();
286  }
287  return $this;
288  }

◆ beforeSave()

beforeSave ( )

Set date of last update for wishlist

Returns
$this

Definition at line 268 of file Wishlist.php.

269  {
270  parent::beforeSave();
271  $this->setUpdatedAt($this->_date->gmtDate());
272  return $this;
273  }

◆ generateSharingCode()

generateSharingCode ( )

Set random sharing code

Returns
$this

Definition at line 231 of file Wishlist.php.

232  {
233  $this->setSharingCode($this->_getSharingRandomCode());
234  return $this;
235  }

◆ getCustomerId()

getCustomerId ( )

Retrieve customer id

Returns
int

Definition at line 500 of file Wishlist.php.

501  {
502  return $this->getData($this->_getResource()->getCustomerIdFieldName());
503  }
getData($key='', $index=null)
Definition: DataObject.php:119

◆ getDataForSave()

getDataForSave ( )

Retrieve data for save

Returns
array

Definition at line 510 of file Wishlist.php.

511  {
512  $data = [];
513  $data[$this->_getResource()->getCustomerIdFieldName()] = $this->getCustomerId();
514  $data['shared'] = (int)$this->getShared();
515  $data['sharing_code'] = $this->getSharingCode();
516  return $data;
517  }

◆ getIdentities()

getIdentities ( )

Return unique ID(s) for each object in system

Returns
array

Implements IdentityInterface.

Definition at line 704 of file Wishlist.php.

705  {
706  $identities = [];
707  if ($this->getId()) {
708  $identities = [self::CACHE_TAG . '_' . $this->getId()];
709  }
710  return $identities;
711  }

◆ getItem()

getItem (   $itemId)

Retrieve wishlist item collection

Parameters
int$itemId
Returns
false|Item

Definition at line 357 of file Wishlist.php.

358  {
359  if (!$itemId) {
360  return false;
361  }
362  return $this->getItemCollection()->getItemById($itemId);
363  }

◆ getItemCollection()

getItemCollection ( )

Retrieve wishlist item collection

Returns
\Magento\Wishlist\Model\ResourceModel\Item\Collection

Definition at line 338 of file Wishlist.php.

339  {
340  if ($this->_itemCollection === null) {
341  $this->_itemCollection = $this->_wishlistCollectionFactory->create()->addWishlistFilter(
342  $this
343  )->addStoreFilter(
344  $this->getSharedStoreIds()
345  )->setVisibilityFilter();
346  }
347 
348  return $this->_itemCollection;
349  }

◆ getItemsCount()

getItemsCount ( )

Retrieve wishlist items count

Returns
int

Definition at line 583 of file Wishlist.php.

584  {
585  return $this->getItemCollection()->count();
586  }

◆ getName()

getName ( )

Retrieve wishlist name

Returns
string

Definition at line 217 of file Wishlist.php.

218  {
219  $name = $this->_getData('name');
220  if ($name === null || !strlen($name)) {
221  return $this->_wishlistData->getDefaultWishlistName();
222  }
223  return $name;
224  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getSharedStoreIds()

getSharedStoreIds ( )

Retrieve shared store ids for current website or all stores if $current is false

Returns
array

Definition at line 524 of file Wishlist.php.

525  {
526  if ($this->_storeIds === null || !is_array($this->_storeIds)) {
527  if ($this->_useCurrentWebsite) {
528  $this->_storeIds = $this->getStore()->getWebsite()->getStoreIds();
529  } else {
530  $_storeIds = [];
531  $stores = $this->_storeManager->getStores();
532  foreach ($stores as $store) {
533  $_storeIds[] = $store->getId();
534  }
535  $this->_storeIds = $_storeIds;
536  }
537  }
538  return $this->_storeIds;
539  }

◆ getStore()

getStore ( )

Retrieve wishlist store object

Returns
\Magento\Store\Model\Store

Definition at line 558 of file Wishlist.php.

559  {
560  if ($this->_store === null) {
561  $this->setStore($this->_storeManager->getStore());
562  }
563  return $this->_store;
564  }

◆ isOwner()

isOwner (   $customerId)

Check customer is owner this wishlist

Parameters
int$customerId
Returns
bool

Definition at line 609 of file Wishlist.php.

610  {
611  return $customerId == $this->getCustomerId();
612  }

◆ isSalable()

isSalable ( )

Retrieve wishlist has salable item(s)

Returns
bool

Definition at line 593 of file Wishlist.php.

594  {
595  foreach ($this->getItemCollection() as $item) {
596  if ($item->getProduct()->getIsSalable()) {
597  return true;
598  }
599  }
600  return false;
601  }

◆ loadByCode()

loadByCode (   $code)

Load by sharing code

Parameters
string$code
Returns
$this

Definition at line 243 of file Wishlist.php.

244  {
245  $this->_getResource()->load($this, $code, 'sharing_code');
246  if (!$this->getShared()) {
247  $this->setId(null);
248  }
249 
250  return $this;
251  }
$code
Definition: info.phtml:12

◆ loadByCustomerId()

loadByCustomerId (   $customerId,
  $create = false 
)

Load wishlist by customer id

Parameters
int$customerId
bool$createCreate wishlist if don't exists
Returns
$this

Definition at line 195 of file Wishlist.php.

196  {
197  if ($customerId === null) {
198  return $this;
199  }
200  $customerId = (int)$customerId;
201  $customerIdFieldName = $this->_getResource()->getCustomerIdFieldName();
202  $this->_getResource()->load($this, $customerId, $customerIdFieldName);
203  if (!$this->getId() && $create) {
204  $this->setCustomerId($customerId);
205  $this->setSharingCode($this->_getSharingRandomCode());
206  $this->save();
207  }
208 
209  return $this;
210  }

◆ setCustomerId()

setCustomerId (   $customerId)

Set customer id

Parameters
int$customerId
Returns
$this

Definition at line 490 of file Wishlist.php.

491  {
492  return $this->setData($this->_getResource()->getCustomerIdFieldName(), $customerId);
493  }

◆ setSharedStoreIds()

setSharedStoreIds (   $storeIds)

Set shared store ids

Parameters
array$storeIds
Returns
$this

Definition at line 547 of file Wishlist.php.

548  {
549  $this->_storeIds = (array)$storeIds;
550  return $this;
551  }

◆ setStore()

setStore (   $store)

Set wishlist store

Parameters
\Magento\Store\Model\Store$store
Returns
$this

Definition at line 572 of file Wishlist.php.

573  {
574  $this->_store = $store;
575  return $this;
576  }

◆ updateItem()

updateItem (   $itemId,
  $buyRequest,
  $params = null 
)

Update wishlist Item and set data from request

The $params sets how current item configuration must be taken into account and additional options. It's passed to \Magento\Catalog\Helper\Product->addParamsToBuyRequest() to compose resulting buyRequest.

Basically it can hold

  • 'current_config', \Magento\Framework\DataObject or array - current buyRequest that configures product in this item, used to restore currently attached files
  • 'files_prefix': string[a-z0-9_] - prefix that was added at frontend to names of file options (file inputs), so they won't intersect with other submitted options

For more options see \Magento\Catalog\Helper\Product->addParamsToBuyRequest()

Parameters
int | Item$itemId
\Magento\Framework\DataObject$buyRequest
null | array | \Magento\Framework\DataObject$params
Returns
$this
Exceptions

Error message

Definition at line 638 of file Wishlist.php.

639  {
640  $item = null;
641  if ($itemId instanceof Item) {
642  $item = $itemId;
643  $itemId = $item->getId();
644  } else {
645  $item = $this->getItem((int)$itemId);
646  }
647  if (!$item) {
648  throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t specify a wish list item.'));
649  }
650 
651  $product = $item->getProduct();
652  $productId = $product->getId();
653  if ($productId) {
654  if (!$params) {
655  $params = new \Magento\Framework\DataObject();
656  } elseif (is_array($params)) {
657  $params = new \Magento\Framework\DataObject($params);
658  }
659  $params->setCurrentConfig($item->getBuyRequest());
660  $buyRequest = $this->_catalogProduct->addParamsToBuyRequest($buyRequest, $params);
661 
662  $product->setWishlistStoreId($item->getStoreId());
663  $items = $this->getItemCollection();
664  $isForceSetQuantity = true;
665  foreach ($items as $_item) {
666  /* @var $_item Item */
667  if ($_item->getProductId() == $product->getId() && $_item->representProduct(
668  $product
669  ) && $_item->getId() != $item->getId()
670  ) {
671  // We do not add new wishlist item, but updating the existing one
672  $isForceSetQuantity = false;
673  }
674  }
675  $resultItem = $this->addNewItem($product, $buyRequest, $isForceSetQuantity);
679  if (is_string($resultItem)) {
680  throw new \Magento\Framework\Exception\LocalizedException(__($resultItem));
681  }
682 
683  if ($resultItem->getId() != $itemId) {
684  if ($resultItem->getDescription() != $item->getDescription()) {
685  $resultItem->setDescription($item->getDescription())->save();
686  }
687  $item->isDeleted(true);
688  $this->setDataChanges(true);
689  } else {
690  $resultItem->setQty($buyRequest->getQty() * 1);
691  $resultItem->setOrigData('qty', 0);
692  }
693  } else {
694  throw new \Magento\Framework\Exception\LocalizedException(__('The product does not exist.'));
695  }
696  return $this;
697  }
addNewItem($product, $buyRequest=null, $forciblySetQty=false)
Definition: Wishlist.php:394
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
__()
Definition: __.php:13
$_item
Definition: default.phtml:11
foreach($product->getExtensionAttributes() ->getBundleProductOptions() as $option) $buyRequest
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
$items

Field Documentation

◆ $_catalogProduct

$_catalogProduct
protected

Definition at line 80 of file Wishlist.php.

◆ $_date

$_date
protected

Definition at line 90 of file Wishlist.php.

◆ $_eventPrefix

$_eventPrefix = 'wishlist'
protected

Definition at line 45 of file Wishlist.php.

◆ $_itemCollection

$_itemCollection
protected

Definition at line 52 of file Wishlist.php.

◆ $_productFactory

$_productFactory
protected

Definition at line 105 of file Wishlist.php.

◆ $_store

$_store
protected

Definition at line 59 of file Wishlist.php.

◆ $_storeIds

$_storeIds
protected

Definition at line 66 of file Wishlist.php.

◆ $_storeManager

$_storeManager
protected

Definition at line 85 of file Wishlist.php.

◆ $_useCurrentWebsite

$_useCurrentWebsite
protected

Definition at line 120 of file Wishlist.php.

◆ $_wishlistCollectionFactory

$_wishlistCollectionFactory
protected

Definition at line 100 of file Wishlist.php.

◆ $_wishlistData

$_wishlistData
protected

Definition at line 73 of file Wishlist.php.

◆ $_wishlistItemFactory

$_wishlistItemFactory
protected

Definition at line 95 of file Wishlist.php.

◆ $dateTime

$dateTime
protected

Definition at line 115 of file Wishlist.php.

◆ $mathRandom

$mathRandom
protected

Definition at line 110 of file Wishlist.php.

◆ $productRepository

$productRepository
protected

Definition at line 125 of file Wishlist.php.

◆ CACHE_TAG

const CACHE_TAG = 'wishlist'

Cache tag

Definition at line 38 of file Wishlist.php.


The documentation for this class was generated from the following file: