本文整理汇总了PHP中Magento\Catalog\Model\Product\Option::getProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::getProduct方法的具体用法?PHP Option::getProduct怎么用?PHP Option::getProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Product\Option
的用法示例。
在下文中一共展示了Option::getProduct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateOptionRequiredFields
/**
* Validate option required fields
*
* @param Option $option
* @return bool
*/
protected function validateOptionRequiredFields(Option $option)
{
$storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
$product = $option->getProduct();
if ($product) {
$storeId = $product->getStoreId();
}
$title = $option->getTitle();
return $this->isValidOptionTitle($title, $storeId) && !$this->isEmpty($option->getType());
}
示例2: validateOptionValue
/**
* Validate option type fields
*
* @param Option $option
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function validateOptionValue(Option $option)
{
$values = $option->getValues() ?: $option->getData('values');
if (!is_array($values) || $this->isEmpty($values)) {
return false;
}
//forbid removal of last value for option
if ($this->checkAllValuesRemoved($values)) {
return false;
}
$storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
if ($option->getProduct()) {
$storeId = $option->getProduct()->getStoreId();
}
foreach ($values as $value) {
$type = isset($value['price_type']) ? $value['price_type'] : null;
$price = isset($value['price']) ? $value['price'] : null;
$title = isset($value['title']) ? $value['title'] : null;
if (!$this->isValidOptionPrice($type, $price, $storeId) || !$this->isValidOptionTitle($title, $storeId)) {
return false;
}
}
return true;
}
示例3: _getPriceConfiguration
/**
* Get price configuration
*
* @param \Magento\Catalog\Model\Product\Option\Value|\Magento\Catalog\Model\Product\Option $option
* @return array
*/
protected function _getPriceConfiguration($option)
{
$optionPrice = $this->pricingHelper->currency($option->getPrice(true), false, false);
$data = ['prices' => ['oldPrice' => ['amount' => $this->pricingHelper->currency($option->getRegularPrice(), false, false), 'adjustments' => []], 'basePrice' => ['amount' => $this->_catalogData->getTaxPrice($option->getProduct(), $optionPrice, false, null, null, null, null, null, false)], 'finalPrice' => ['amount' => $this->_catalogData->getTaxPrice($option->getProduct(), $optionPrice, true, null, null, null, null, null, false)]], 'type' => $option->getPriceType(), 'name' => $option->getTitle()];
return $data;
}
示例4: _getPriceConfiguration
/**
* Get price configuration
*
* @param \Magento\Catalog\Model\Product\Option\Value|\Magento\Catalog\Model\Product\Option $option
* @return array
*/
protected function _getPriceConfiguration($option)
{
$data = array();
$data['price'] = $this->_coreData->currency($option->getPrice(true), false, false);
$data['oldPrice'] = $this->_coreData->currency($option->getPrice(false), false, false);
$data['priceValue'] = $option->getPrice(false);
$data['type'] = $option->getPriceType();
$data['exclTaxPrice'] = $price = $this->_catalogData->getTaxPrice($option->getProduct(), $data['price'], false);
$data['inclTaxPrice'] = $price = $this->_catalogData->getTaxPrice($option->getProduct(), $data['price'], true);
return $data;
}