當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Product::getSkipSaleableCheck方法代碼示例

本文整理匯總了PHP中Magento\Catalog\Helper\Product::getSkipSaleableCheck方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::getSkipSaleableCheck方法的具體用法?PHP Product::getSkipSaleableCheck怎麽用?PHP Product::getSkipSaleableCheck使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Catalog\Helper\Product的用法示例。


在下文中一共展示了Product::getSkipSaleableCheck方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getOptions

 /**
  * @return array
  */
 public function getOptions()
 {
     if (!$this->options) {
         $product = $this->getProduct();
         $typeInstance = $product->getTypeInstance();
         $typeInstance->setStoreFilter($product->getStoreId(), $product);
         $optionCollection = $typeInstance->getOptionsCollection($product);
         $selectionCollection = $typeInstance->getSelectionsCollection($typeInstance->getOptionsIds($product), $product);
         $this->options = $optionCollection->appendSelections($selectionCollection, false, $this->catalogProduct->getSkipSaleableCheck());
     }
     return $this->options;
 }
開發者ID:Coplex,項目名稱:magento2,代碼行數:15,代碼來源:Bundle.php

示例2: checkProductBuyState

 /**
  * Check if product can be bought
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function checkProductBuyState($product)
 {
     parent::checkProductBuyState($product);
     $productOptionIds = $this->getOptionsIds($product);
     $productSelections = $this->getSelectionsCollection($productOptionIds, $product);
     $selectionIds = $product->getCustomOption('bundle_selection_ids');
     $selectionIds = unserialize($selectionIds->getValue());
     $buyRequest = $product->getCustomOption('info_buyRequest');
     $buyRequest = new \Magento\Framework\DataObject(unserialize($buyRequest->getValue()));
     $bundleOption = $buyRequest->getBundleOption();
     if (empty($bundleOption)) {
         throw new \Magento\Framework\Exception\LocalizedException($this->getSpecifyOptionMessage());
     }
     $skipSaleableCheck = $this->_catalogProduct->getSkipSaleableCheck();
     foreach ($selectionIds as $selectionId) {
         /* @var $selection \Magento\Bundle\Model\Selection */
         $selection = $productSelections->getItemById($selectionId);
         if (!$selection || !$selection->isSalable() && !$skipSaleableCheck) {
             throw new \Magento\Framework\Exception\LocalizedException(__('The required options you selected are not available.'));
         }
     }
     $product->getTypeInstance()->setStoreFilter($product->getStoreId(), $product);
     $optionsCollection = $this->getOptionsCollection($product);
     foreach ($optionsCollection->getItems() as $option) {
         if ($option->getRequired() && empty($bundleOption[$option->getId()])) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Please select all required options.'));
         }
     }
     return $this;
 }
開發者ID:rafaelstz,項目名稱:magento2,代碼行數:37,代碼來源:Type.php

示例3: getAllowProducts

 /**
  * Get Allowed Products
  *
  * @return array
  */
 public function getAllowProducts()
 {
     if (!$this->hasAllowProducts()) {
         $products = [];
         $skipSaleableCheck = $this->catalogProduct->getSkipSaleableCheck();
         $allProducts = $this->getProduct()->getTypeInstance()->getUsedProducts($this->getProduct(), null);
         foreach ($allProducts as $product) {
             if ($product->isSaleable() || $skipSaleableCheck) {
                 $products[] = $product;
             }
         }
         $this->setAllowProducts($products);
     }
     return $this->getData('allow_products');
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:20,代碼來源:Configurable.php

示例4: isAvailable

 /**
  * Check whether the product type or stock allows to purchase the product
  *
  * @return bool
  */
 public function isAvailable()
 {
     return $this->getTypeInstance()->isSalable($this) || $this->_catalogProduct->getSkipSaleableCheck();
 }
開發者ID:nblair,項目名稱:magescotch,代碼行數:9,代碼來源:Product.php


注:本文中的Magento\Catalog\Helper\Product::getSkipSaleableCheck方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。