コード例 #1
0
 /**
  * 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
0
ファイル: Select.php プロジェクト: Doability/magento2dev
 /**
  * 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
0
 /**
  * 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
0
ファイル: Options.php プロジェクト: aiesh/magento2
 /**
  * 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;
 }