本文整理汇总了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;
}
示例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;
}
示例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');
}
示例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();
}