77namespace Magento \Wishlist \Model ;
88
99use Magento \Catalog \Api \ProductRepositoryInterface ;
10- use Magento \Catalog \Model \Product ;
1110use Magento \Catalog \Model \Product \Configuration \Item \ItemInterface ;
12- use Magento \Framework \App \ObjectManager ;
1311use Magento \Framework \Exception \NoSuchEntityException ;
1412use Magento \Framework \Model \AbstractModel ;
15- use Magento \PageCache \Model \Cache \Type as PageCache ;
1613use Magento \Wishlist \Model \Item \Option ;
1714use Magento \Wishlist \Model \Item \OptionFactory ;
1815use Magento \Wishlist \Model \ResourceModel \Item \Option \CollectionFactory ;
3229 * @method string getDescription()
3330 * @method \Magento\Wishlist\Model\Item setDescription(string $value)
3431 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
35- * @SuppressWarnings(PHPMD.TooManyFields)
3632 *
3733 * @api
3834 * @since 100.0.2
@@ -76,7 +72,7 @@ class Item extends AbstractModel implements ItemInterface
7672 protected $ _optionsByCode = [];
7773
7874 /**
79- * Initialization of Not Represent options
75+ * Not Represent options
8076 *
8177 * @var string[]
8278 */
@@ -131,11 +127,6 @@ class Item extends AbstractModel implements ItemInterface
131127 */
132128 private $ serializer ;
133129
134- /**
135- * @var PageCache
136- */
137- private $ pageCache ;
138-
139130 /**
140131 * @param \Magento\Framework\Model\Context $context
141132 * @param \Magento\Framework\Registry $registry
@@ -150,7 +141,6 @@ class Item extends AbstractModel implements ItemInterface
150141 * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
151142 * @param array $data
152143 * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
153- * @param PageCache|null $pageCache
154144 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
155145 */
156146 public function __construct (
@@ -166,20 +156,18 @@ public function __construct(
166156 \Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
167157 \Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
168158 array $ data = [],
169- \Magento \Framework \Serialize \Serializer \Json $ serializer = null ,
170- ?PageCache $ pageCache = null
159+ \Magento \Framework \Serialize \Serializer \Json $ serializer = null
171160 ) {
172161 $ this ->productTypeConfig = $ productTypeConfig ;
173162 $ this ->_storeManager = $ storeManager ;
174163 $ this ->_date = $ date ;
175164 $ this ->_catalogUrl = $ catalogUrl ;
176165 $ this ->_wishlistOptFactory = $ wishlistOptFactory ;
177166 $ this ->_wishlOptionCollectionFactory = $ wishlOptionCollectionFactory ;
178- $ this ->serializer = $ serializer ?: ObjectManager::getInstance ()
167+ $ this ->serializer = $ serializer ?: \ Magento \ Framework \ App \ ObjectManager::getInstance ()
179168 ->get (\Magento \Framework \Serialize \Serializer \Json::class);
180169 parent ::__construct ($ context , $ registry , $ resource , $ resourceCollection , $ data );
181170 $ this ->productRepository = $ productRepository ;
182- $ this ->pageCache = $ pageCache ?: ObjectManager::getInstance ()->get (PageCache::class);
183171 }
184172
185173 /**
@@ -228,8 +216,8 @@ protected function _compareOptions($options1, $options2)
228216 /**
229217 * Register option code
230218 *
231- * @param Option $option
232- * @return $this
219+ * @param Option $option
220+ * @return $this
233221 * @throws \Magento\Framework\Exception\LocalizedException
234222 */
235223 protected function _addOptionCode ($ option )
@@ -246,7 +234,6 @@ protected function _addOptionCode($option)
246234
247235 /**
248236 * Checks that item model has data changes.
249- *
250237 * Call save item options if model isn't need to save in DB
251238 *
252239 * @return boolean
@@ -312,7 +299,6 @@ public function isOptionsSaved()
312299 public function afterSave ()
313300 {
314301 $ this ->saveItemOptions ();
315- $ this ->cleanProductCache ($ this ->getProductId ());
316302 return parent ::afterSave ();
317303 }
318304
@@ -412,7 +398,7 @@ public function getProduct()
412398 * Return false for disabled or unvisible products
413399 *
414400 * @param \Magento\Checkout\Model\Cart $cart
415- * @param bool $delete delete the item after successful add to cart
401+ * @param bool $delete delete the item after successful add to cart
416402 * @return bool
417403 * @throws \Magento\Catalog\Model\Product\Exception
418404 */
@@ -479,7 +465,8 @@ public function getProductUrl()
479465 }
480466
481467 /**
482- * Returns formatted buy request - object, holding request received from product view page with keys and options
468+ * Returns formatted buy request - object, holding request received from
469+ * product view page with keys and options for configured product
483470 *
484471 * @return \Magento\Framework\DataObject
485472 */
@@ -527,7 +514,8 @@ public function mergeBuyRequest($buyRequest)
527514 }
528515
529516 /**
530- * Set buy request - object, holding request received from product view page with keys and options
517+ * Set buy request - object, holding request received from
518+ * product view page with keys and options for configured product
531519 *
532520 * @param \Magento\Framework\DataObject $buyRequest
533521 * @return $this
@@ -556,10 +544,10 @@ public function isRepresent($product, $buyRequest)
556544
557545 $ selfOptions = $ this ->getBuyRequest ()->getData ();
558546
559- if (false === $ buyRequest && !empty ($ selfOptions )) {
547+ if (empty ( $ buyRequest) && !empty ($ selfOptions )) {
560548 return false ;
561549 }
562- if (empty ($ selfOptions ) && false !== $ buyRequest ) {
550+ if (empty ($ selfOptions ) && ! empty ( $ buyRequest) ) {
563551 if (!$ product ->isComposite ()) {
564552 return true ;
565553 } else {
@@ -663,8 +651,8 @@ public function getOptionsByCode()
663651 /**
664652 * Add option to item
665653 *
666- * @param Option|\Magento\Framework\DataObject|array $option
667- * @return $this
654+ * @param Option|\Magento\Framework\DataObject|array $option
655+ * @return $this
668656 * @throws \Magento\Framework\Exception\LocalizedException
669657 */
670658 public function addOption ($ option )
@@ -754,7 +742,6 @@ public function setCustomDownloadUrl($url)
754742
755743 /**
756744 * Returns special download params (if needed) for custom option with type = 'file'.
757- *
758745 * Needed to implement \Magento\Catalog\Model\Product\Configuration\Item\Interface.
759746 *
760747 * We have to customize only controller url, so return it.
@@ -793,20 +780,4 @@ public function loadWithOptions($id, $optionsFilter = null)
793780 $ this ->setOptions ($ options ->getOptionsByItem ($ this ));
794781 return $ this ;
795782 }
796-
797- /**
798- * Cleans up cache for single product when wishlist item updated (for product qty).
799- *
800- * @param int $productId
801- * @return void
802- */
803- private function cleanProductCache ($ productId ): void
804- {
805- if (!empty ($ productId )) {
806- $ this ->pageCache ->clean (
807- \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG ,
808- [Product::CACHE_TAG . '_ ' . $ productId ]
809- );
810- }
811- }
812783}
0 commit comments