当前位置: 首页>>代码示例>>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;未经允许,请勿转载。