Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Item.php
Go to the documentation of this file.
1 <?php
13 
19 {
25  protected function _construct()
26  {
27  $this->_init('wishlist_item', 'wishlist_item_id');
28  }
29 
39  public function loadByProductWishlist($object, $wishlistId, $productId, $sharedStores)
40  {
41  $connection = $this->getConnection();
42  $storeWhere = $connection->quoteInto('store_id IN (?)', $sharedStores);
43  $select = $connection->select()->from(
44  $this->getMainTable()
45  )->where(
46  'wishlist_id=:wishlist_id AND ' . 'product_id=:product_id AND ' . $storeWhere
47  );
48  $bind = ['wishlist_id' => $wishlistId, 'product_id' => $productId];
49  $data = $connection->fetchRow($select, $bind);
50  if ($data) {
51  $object->setData($data);
52  }
53  $this->_afterLoad($object);
54 
55  return $this;
56  }
57 
61  public function save(\Magento\Framework\Model\AbstractModel $object)
62  {
63  $hasDataChanges = $object->hasDataChanges();
64  $object->setIsOptionsSaved(false);
65 
66  $result = parent::save($object);
67 
68  if ($hasDataChanges && !$object->isOptionsSaved()) {
69  $object->saveItemOptions();
70  }
71  return $result;
72  }
73 }
loadByProductWishlist($object, $wishlistId, $productId, $sharedStores)
Definition: Item.php:39
$connection
Definition: bulk.php:13
save(\Magento\Framework\Model\AbstractModel $object)
Definition: Item.php:61
_afterLoad(\Magento\Framework\Model\AbstractModel $object)
Definition: AbstractDb.php:641