Пример #1
0
 protected function setUp()
 {
     $mockedResource = $this->getMockedResource();
     $mockedCollectionFactory = $this->getMockedValueCollectionFactory();
     $mockedContext = $this->getMockedContext();
     $helper = new ObjectManager($this);
     $this->model = $helper->getObject('\\Magento\\Catalog\\Model\\Product\\Option\\Value', ['resource' => $mockedResource, 'valueCollectionFactory' => $mockedCollectionFactory, 'context' => $mockedContext]);
     $this->model->setOption($this->getMockedOption());
 }
 /**
  * {@inheritdoc}
  */
 public function getData()
 {
     if (!$this->getCollection()->isLoaded()) {
         $currentProductId = (int) $this->request->getParam('current_product_id');
         if (0 !== $currentProductId) {
             $this->getCollection()->getSelect()->where('e.entity_id != ?', $currentProductId);
         }
         $this->getCollection()->getSelect()->distinct()->join(['opt' => $this->getCollection()->getTable('catalog_product_option')], 'opt.product_id = e.entity_id', null);
         $this->getCollection()->load();
         /** @var ProductInterface $product */
         foreach ($this->getCollection() as $product) {
             $options = [];
             /** @var ProductOption|DataObject $option */
             foreach ($this->productOptionRepository->getProductOptions($product) as $option) {
                 $option->setData('values', $this->productOptionValueModel->getValuesCollection($option)->toArray()['items']);
                 $options[] = $option->toArray();
             }
             $product->setOptions($options);
         }
     }
     $items = $this->getCollection()->toArray();
     return ['totalRecords' => $this->getCollection()->getSize(), 'items' => array_values($items)];
 }
Пример #3
0
 /**
  * Get collection of values by given option ids
  *
  * @param array $optionIds
  * @param int $storeId
  * @return Collection
  */
 public function getOptionValuesByOptionId($optionIds, $storeId)
 {
     $collection = $this->productOptionValue->getValuesByOption($optionIds, $this->getId(), $storeId);
     return $collection;
 }
Пример #4
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;
 }
Пример #5
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;
 }