jsonFactory->create(); $customerId = (int)$this->customerSession->getCustomerId(); $productId = (int)$this->request->getParam('product_id'); if (!$customerId || !$productId) { return $result->setData(['active' => false]); } $wishlist = $this->wishlistFactory->create()->loadByCustomerId($customerId, false); if (!$wishlist->getId()) { return $result->setData(['active' => false]); } $connection = $this->resourceConnection->getConnection(); $active = $connection->fetchOne( $connection->select() ->from( $this->resourceConnection->getTableName('wishlist_item'), ['wishlist_item_id'] ) ->where('wishlist_id = ?', (int)$wishlist->getId()) ->where('product_id = ?', $productId) ->limit(1) ) !== false; return $result->setData(['active' => $active]); } }