|
| __construct (\Magento\Framework\App\Helper\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Customer\Model\Session $customerSession, \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Data\Helper\PostHelper $postDataHelper, \Magento\Customer\Helper\View $customerViewHelper, WishlistProviderInterface $wishlistProvider, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository) |
|
| setCustomer (\Magento\Customer\Api\Data\CustomerInterface $customer) |
|
| getCustomer () |
|
| getWishlist () |
|
| getItemCount () |
|
| getWishlistItemCollection () |
|
| getRemoveParams ($item, $addReferer=false) |
|
| getConfigureUrl ($item) |
|
| getAddParams ($item, array $params=[]) |
|
| getMoveFromCartParams ($itemId) |
|
| getUpdateParams ($item) |
|
| getAddToCartUrl ($item) |
|
| getAddToCartParams ($item, $addReferer=false) |
|
| addRefererToParams (array $params) |
|
| getSharedAddToCartUrl ($item) |
|
| getSharedAddAllToCartUrl () |
|
| getListUrl ($wishlistId=null) |
|
| isAllow () |
|
| isAllowInCart () |
|
| getCustomerName () |
|
| getRssUrl ($wishlistId=null) |
|
| defaultCommentString () |
|
| getDefaultWishlistName () |
|
| calculate () |
|
| isDisplayQty () |
|
| getProductUrl ($item, $additional=[]) |
|
| __construct (Context $context) |
|
| isModuleOutputEnabled ($moduleName=null) |
|
Wishlist Data Helper
- Author
- Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@api
- Since
- 100.0.2
Definition at line 20 of file Data.php.
◆ __construct()
- Parameters
-
\Magento\Framework\App\Helper\Context | $context | |
\Magento\Framework\Registry | $coreRegistry | |
\Magento\Customer\Model\Session | $customerSession | |
\Magento\Wishlist\Model\WishlistFactory | $wishlistFactory | |
\Magento\Store\Model\StoreManagerInterface | $storeManager | |
\Magento\Framework\Data\Helper\PostHelper | $postDataHelper | |
\Magento\Customer\Helper\View | $customerViewHelper | |
WishlistProviderInterface | $wishlistProvider | |
\Magento\Catalog\Api\ProductRepositoryInterface | $productRepository | |
Definition at line 113 of file Data.php.
124 $this->_coreRegistry = $coreRegistry;
125 $this->_customerSession = $customerSession;
126 $this->_wishlistFactory = $wishlistFactory;
128 $this->_postDataHelper = $postDataHelper;
129 $this->_customerViewHelper = $customerViewHelper;
132 parent::__construct($context);
◆ _createWishlistItemCollection()
_createWishlistItemCollection |
( |
| ) |
|
|
protected |
Create wishlist item collection
- Returns
- \Magento\Wishlist\Model\ResourceModel\Item\Collection
Definition at line 232 of file Data.php.
◆ _getCartUrlParameters()
_getCartUrlParameters |
( |
|
$item | ) |
|
|
protected |
Get cart URL parameters
- Parameters
-
string | \Magento\Catalog\Model\Product | \Magento\Wishlist\Model\Item | $item | |
- Returns
- array
Definition at line 459 of file Data.php.
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ _getCurrentCustomer()
Retrieve logged in customer
- Returns
- \Magento\Customer\Api\Data\CustomerInterface
Definition at line 150 of file Data.php.
◆ _getUrlStore()
Retrieve Item Store for URL
- Parameters
-
\Magento\Catalog\Model\Product | \Magento\Wishlist\Model\Item | $item | |
- Returns
- \Magento\Store\Model\Store
Definition at line 256 of file Data.php.
266 if (
$product->isVisibleInSiteVisibility()) {
274 return $this->_storeManager->getStore(
$storeId);
elseif(isset( $params[ 'redirect_parent']))
◆ _isCustomerLogIn()
Retrieve customer login status
- Returns
- bool
Definition at line 140 of file Data.php.
142 return $this->_customerSession->isLoggedIn();
◆ addRefererToParams()
addRefererToParams |
( |
array |
$params | ) |
|
Add UENC referer to params
- Parameters
-
- Returns
- array
Definition at line 420 of file Data.php.
423 $this->urlEncoder->encode($this->
_getRequest()->getServer(
'HTTP_REFERER'));
const PARAM_NAME_URL_ENCODED
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ calculate()
Calculate count of wishlist items and put value to customer session. Method called after wishlist modifications and trigger 'wishlist_items_renewed' event. Depends from configuration.
- Returns
- $this
Definition at line 570 of file Data.php.
575 if ($this->scopeConfig->getValue(
576 self::XML_PATH_WISHLIST_LINK_USE_QTY,
577 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
584 $this->_customerSession->setWishlistDisplayType(
585 $this->scopeConfig->getValue(
586 self::XML_PATH_WISHLIST_LINK_USE_QTY,
587 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
590 $this->_customerSession->setDisplayOutOfStockProducts(
591 $this->scopeConfig->getValue(
592 self::XML_PATH_CATALOGINVENTORY_SHOW_OUT_OF_STOCK,
593 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
597 $this->_customerSession->setWishlistItemCount(
$count);
598 $this->_eventManager->dispatch(
'wishlist_items_renewed');
getWishlistItemCollection()
◆ defaultCommentString()
Retrieve default empty comment message
- Returns
- \Magento\Framework\Phrase
Definition at line 548 of file Data.php.
550 return __(
'Comment');
◆ getAddParams()
getAddParams |
( |
|
$item, |
|
|
array |
$params = [] |
|
) |
| |
Retrieve params for adding product to wishlist
- Parameters
-
\Magento\Catalog\Model\Product | \Magento\Wishlist\Model\Item | $item | |
array | $params | |
- Returns
- string
Definition at line 321 of file Data.php.
336 return $this->_postDataHelper->getPostData(
$url,
$params);
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ getAddToCartParams()
getAddToCartParams |
( |
|
$item, |
|
|
|
$addReferer = false |
|
) |
| |
Retrieve URL for adding item to shopping cart
- Parameters
-
string | \Magento\Catalog\Model\Product | \Magento\Wishlist\Model\Item | $item | |
bool | $addReferer | |
- Returns
- string
Definition at line 399 of file Data.php.
408 return $this->_postDataHelper->getPostData(
_getCartUrlParameters($item)
const PARAM_NAME_URL_ENCODED
addRefererToParams(array $params)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ getAddToCartUrl()
Retrieve params for adding item to shopping cart
- Parameters
-
string | \Magento\Catalog\Model\Product | \Magento\Wishlist\Model\Item | $item | |
- Returns
- string
Definition at line 387 of file Data.php.
_getCartUrlParameters($item)
◆ getConfigureUrl()
Retrieve URL for configuring item from wishlist
- Parameters
-
\Magento\Catalog\Model\Product | \Magento\Wishlist\Model\Item | $item | |
- Returns
- string
Definition at line 303 of file Data.php.
306 'wishlist/index/configure',
308 'id' =>
$item->getWishlistItemId(),
309 'product_id' =>
$item->getProductId()
_getUrl($route, $params=[])
◆ getCustomer()
Retrieve current customer
- Returns
- \Magento\Customer\Api\Data\CustomerInterface|null
Definition at line 171 of file Data.php.
173 if (!$this->_currentCustomer && $this->_customerSession->isLoggedIn()) {
174 $this->_currentCustomer = $this->_customerSession->getCustomerDataObject();
◆ getCustomerName()
Retrieve customer name
- Returns
- string|null
Definition at line 517 of file Data.php.
520 ? $this->_customerViewHelper->getCustomerName($this->
getCustomer())
◆ getDefaultWishlistName()
getDefaultWishlistName |
( |
| ) |
|
Retrieve default empty comment message
- Returns
- \Magento\Framework\Phrase
Definition at line 558 of file Data.php.
560 return __(
'Wish List');
◆ getItemCount()
Retrieve wishlist item count (include config settings)
Used in top link menu only
- Returns
- int
Definition at line 203 of file Data.php.
205 $storedDisplayType = $this->_customerSession->getWishlistDisplayType();
206 $currentDisplayType = $this->scopeConfig->getValue(
207 self::XML_PATH_WISHLIST_LINK_USE_QTY,
208 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
211 $storedDisplayOutOfStockProducts = $this->_customerSession->getDisplayOutOfStockProducts();
212 $currentDisplayOutOfStockProducts = $this->scopeConfig->getValue(
213 self::XML_PATH_CATALOGINVENTORY_SHOW_OUT_OF_STOCK,
214 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
216 if (!$this->_customerSession->hasWishlistItemCount() ||
217 $currentDisplayType != $storedDisplayType ||
218 $this->_customerSession->hasDisplayOutOfStockProducts() ||
219 $currentDisplayOutOfStockProducts != $storedDisplayOutOfStockProducts
224 return $this->_customerSession->getWishlistItemCount();
◆ getListUrl()
getListUrl |
( |
|
$wishlistId = null | ) |
|
Retrieve customer wishlist url
- Parameters
-
- Returns
- string
Definition at line 476 of file Data.php.
480 $params[
'wishlist_id'] = $wishlistId;
_getUrl($route, $params=[])
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ getMoveFromCartParams()
getMoveFromCartParams |
( |
|
$itemId | ) |
|
Retrieve params for adding product to wishlist
- Parameters
-
- Returns
- string
Definition at line 346 of file Data.php.
350 return $this->_postDataHelper->getPostData(
$url,
$params);
_getUrl($route, $params=[])
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ getProductUrl()
getProductUrl |
( |
|
$item, |
|
|
|
$additional = [] |
|
) |
| |
Retrieve URL to item Product
- Parameters
-
\Magento\Wishlist\Model\Item | \Magento\Catalog\Model\Product | $item | |
array | $additional | |
- Returns
- string
Definition at line 622 of file Data.php.
633 $product = $this->productRepository->getById(
636 $this->_storeManager->getStore()->getStoreId()
foreach($product->getExtensionAttributes() ->getBundleProductOptions() as $option) $buyRequest
◆ getRemoveParams()
getRemoveParams |
( |
|
$item, |
|
|
|
$addReferer = false |
|
) |
| |
Retrieve params for removing item from wishlist
- Parameters
-
\Magento\Catalog\Model\Product | \Magento\Wishlist\Model\Item | $item | |
bool | $addReferer | |
- Returns
- string
Definition at line 284 of file Data.php.
294 return $this->_postDataHelper->getPostData(
$url,
$params);
const PARAM_NAME_URL_ENCODED
_getUrl($route, $params=[])
addRefererToParams(array $params)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ getRssUrl()
getRssUrl |
( |
|
$wishlistId = null | ) |
|
Retrieve RSS URL
- Parameters
-
int | string | null | $wishlistId | |
- Returns
- string
Definition at line 530 of file Data.php.
535 $params = [
'data' => $this->urlEncoder->encode($key),
'_secure' =>
false];
538 $params[
'wishlist_id'] = $wishlistId;
_getUrl($route, $params=[])
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ getSharedAddAllToCartUrl()
getSharedAddAllToCartUrl |
( |
| ) |
|
Retrieve URL for adding All items to shopping cart from shared wishlist
- Returns
- string
Definition at line 446 of file Data.php.
448 return $this->_postDataHelper->getPostData(
449 $this->_storeManager->getStore()->getUrl(
'*/*/allcart', [
'_current' =>
true])
◆ getSharedAddToCartUrl()
getSharedAddToCartUrl |
( |
|
$item | ) |
|
Retrieve URL for adding item to shopping cart from shared wishlist
- Parameters
-
string | \Magento\Catalog\Model\Product | \Magento\Wishlist\Model\Item | $item | |
- Returns
- string
Definition at line 433 of file Data.php.
435 return $this->_postDataHelper->getPostData(
_getCartUrlParameters($item)
◆ getUpdateParams()
Retrieve params for updating product in wishlist
- Parameters
-
\Magento\Catalog\Model\Product | \Magento\Wishlist\Model\Item | $item | |
- Returns
- string|false
Definition at line 360 of file Data.php.
364 $itemId =
$item->getWishlistItemId();
368 $itemId =
$item->getId();
372 $url = $this->
_getUrl(
'wishlist/index/updateItemOptions');
375 return $this->_postDataHelper->getPostData(
$url,
$params);
_getUrl($route, $params=[])
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ getWishlist()
Retrieve wishlist by logged in customer
- Returns
- \Magento\Wishlist\Model\Wishlist
Definition at line 184 of file Data.php.
186 if ($this->_wishlist ===
null) {
187 if ($this->_coreRegistry->registry(
'shared_wishlist')) {
188 $this->_wishlist = $this->_coreRegistry->registry(
'shared_wishlist');
190 $this->_wishlist = $this->wishlistProvider->getWishlist();
◆ getWishlistItemCollection()
getWishlistItemCollection |
( |
| ) |
|
Retrieve wishlist items collection
- Returns
- \Magento\Wishlist\Model\ResourceModel\Item\Collection
Definition at line 242 of file Data.php.
244 if ($this->_wishlistItemCollection ===
null) {
_createWishlistItemCollection()
◆ isAllow()
Check is allow wishlist module
- Returns
- bool
Definition at line 490 of file Data.php.
492 if ($this->_moduleManager->isOutputEnabled($this->_getModuleName()) && $this->scopeConfig->getValue(
493 'wishlist/general/active',
494 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
◆ isAllowInCart()
Check is allow wishlist action in shopping cart
- Returns
- bool
Definition at line 507 of file Data.php.
◆ isDisplayQty()
Should display item quantities in my wishlist link
- Returns
- bool
Definition at line 607 of file Data.php.
609 return $this->scopeConfig->getValue(
610 self::XML_PATH_WISHLIST_LINK_USE_QTY,
611 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
◆ setCustomer()
Set current customer
- Parameters
-
\Magento\Customer\Api\Data\CustomerInterface | $customer | |
- Returns
- void
Definition at line 161 of file Data.php.
◆ $_coreRegistry
◆ $_currentCustomer
◆ $_customerSession
◆ $_customerViewHelper
◆ $_postDataHelper
◆ $_productCollection
◆ $_storeManager
◆ $_wishlist
◆ $_wishlistFactory
◆ $_wishlistItemCollection
◆ $productRepository
◆ $wishlistProvider
◆ XML_PATH_CATALOGINVENTORY_SHOW_OUT_OF_STOCK
const XML_PATH_CATALOGINVENTORY_SHOW_OUT_OF_STOCK = 'cataloginventory/options/show_out_of_stock' |
Config key 'Display Out of Stock Products'
Definition at line 30 of file Data.php.
◆ XML_PATH_WISHLIST_LINK_USE_QTY
const XML_PATH_WISHLIST_LINK_USE_QTY = 'wishlist/wishlist_link/use_qty' |
The documentation for this class was generated from the following file:
- vendor/magento/module-wishlist/Helper/Data.php