/**
  * {@inheritdoc}
  */
 public function getList($sku, $websiteId = null)
 {
     $product = $this->productRepository->get($sku, true);
     $priceKey = 'website_price';
     $value = $this->config->getValue('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE);
     if ($value == 0) {
         $priceKey = 'price';
     }
     $prices = [];
     foreach ($product->getData('group_price') as $price) {
         /** @var \Magento\Catalog\Api\Data\ProductGroupPriceInterface $groupPrice */
         $groupPrice = $this->groupPriceFactory->create();
         $groupPrice->setCustomerGroupId($price['all_groups'] ? 'all' : $price['cust_group'])->setValue($price[$priceKey]);
         $prices[] = $groupPrice;
     }
     return $prices;
 }
Exemplo n.º 2
0
 /**
  * Gets list of product group prices
  *
  * @param Product $product
  * @return \Magento\Catalog\Api\Data\ProductGroupPriceInterface[]
  */
 public function getGroupPrices($product)
 {
     $prices = [];
     $groupPrices = $this->getExistingPrices($product, 'group_price');
     foreach ($groupPrices as $price) {
         /** @var \Magento\Catalog\Api\Data\ProductGroupPriceInterface $groupPrice */
         $groupPrice = $this->groupPriceFactory->create();
         $groupPrice->setCustomerGroupId($price['cust_group']);
         if (array_key_exists('website_price', $price)) {
             $value = $price['website_price'];
         } else {
             $value = $price['price'];
         }
         $groupPrice->setValue($value);
         $prices[] = $groupPrice;
     }
     return $prices;
 }