Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function read(\Magento\Catalog\Model\Product\Option $option)
 {
     $fields = [Metadata::PRICE => $option->getPrice(), Metadata::PRICE_TYPE => $option->getPriceType(), Metadata::SKU => $option->getSku()];
     $fields = array_merge($fields, $this->getCustomAttributes($option));
     $value = $this->valueBuilder->populateWithArray($fields)->create();
     return [$value];
 }
 /**
  * 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;
 }
 /**
  * Validate option type fields
  *
  * @param Option $option
  * @return bool
  */
 protected function validateOptionValue(Option $option)
 {
     return $this->isInRange($option->getPriceType(), $this->priceTypes) && !$this->isNegative($option->getPrice());
 }
Beispiel #4
0
 /**
  * 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;
 }