@param string $sku
@param float  $qty
@param string $ean

@return Variation
553595
public function addVariation($sku, $qty = 0.0000, $ean = null)
    {
        $variations = $this->getVariations();
        $variation  = new Variation($this->requestHandler());

        $variation->setSku($sku)
            ->setQty($qty)
            ->setEan($ean);
        
        /** @var Variation $_variation */
        foreach ($variations as $_variation) {
            if ($_variation->getSku() == $sku) {
                return $_variation;
            }
        }
        
        $variations[] = $variation;
        
        $this->setData('variations', $variations);
        
        return $variation;
    }
318472
public function getStock(string $sku) {
    $query = $this->connection->select('acm_sku_stock');
    $query->fields('acm_sku_stock');
    $query->condition('sku', $sku);
    $result = $query->execute()->fetchAll();

    // We may not have any entry.
    if (empty($result)) {
      return [];
    }

    // Log if more than one found.
    if (count($result) > 1) {
      $this->logger->error('Duplicate entries found for stock of sku @sku.', [
        '@sku' => $sku,
      ]);
    }

    // Get the first result.
    $data = reset($result);

    return (array) $data;
  }
630070
public function create($type, $set, $sku, $productData, $storeView = null)
    {
        return $this->__createAction('catalog_product.create', func_get_args());
    }
1261138
public function mapSkuToRowId($sku)
    {

        // query weather or not the SKU has been mapped
        if (isset($this->skuRowIdMapping[$sku])) {
            return $this->skuRowIdMapping[$sku];
        }

        // throw an exception if the SKU has not been mapped yet
        throw new \Exception(sprintf('Found not mapped SKU %s', $sku));
    }
382123
private function getItemBySku(string $sku, int $quantity): CartItem
    {
        $qb = $this->connection->createQueryBuilder();
        $qb->select('*')
            ->from('dumplie_inventory_product')
            ->where('sku = :sku')
            ->setParameter('sku', $sku);

        $itemData = $this->connection->fetchAssoc($qb->getSQL(), $qb->getParameters());

        if (empty($itemData)) {
            throw QueryException::cartItemNotFound($sku);
        }

        return new CartItem(
            $itemData['sku'],
            $quantity,
            $itemData['price_amount'] / $itemData['price_precision'],
            $itemData['price_currency'],
            $this->mao->getBy([Metadata::FIELD_SKU => $itemData['sku']])
        );
    }
1231935
private function getVarValue($sKey, $aVars)
    {
        foreach ($aVars as $aVar) {
            if ($sKey == $aVar['key']) {
                return $aVar['value'];
            }
        }

        return null;
    }
344816
public function update($sku)
    {
        if (!Input::has('product')) {
            return $this->jsonErrorResponse('"product" is required.');
        }

        $product = Subbly::api('subbly.product')->update($sku, Input::get('product'), Input::get('locale', null));

        return $this->jsonResponse(array(
            'product' => $this->presenter->single($product),
        ),
        array(
            'status' => array('message' => 'Product updated'),
        ));
    }
1096225
public function getBySku(SKU $SKU): Product
    {
        if (isset($this->products[(string) $SKU])) {
            return $this->products[(string) $SKU];
        }

        throw ProductNotFound::bySku($SKU);
    }
845401
public function processStockMessage(array $stock, $store_id = 0) {
    // Sanity check.
    if (!isset($stock['sku']) || !strlen($stock['sku'])) {
      $this->logger->error('Invalid or empty product SKU. Stock message: @message', [
        '@message' => json_encode($stock),
      ]);

      return;
    }

    $langcode = NULL;

    if (empty($store_id) && isset($stock['store_id'])) {
      $store_id = $stock['store_id'];
    }

    // Check for stock is valid for current site.
    // If store id not available, we consider it as valid message.
    if ($store_id) {
      $langcode = $this->i18nHelper->getLangcodeFromStoreId($store_id);

      if (empty($langcode)) {
        // It could be for a different store/website, don't do anything.
        $this->logger->info('Ignored stock message for different store. Message: @message', [
          '@message' => json_encode($stock),
        ]);

        return;
      }
    }

    // We get qty in product data and quantity in stock push or from stock api.
    $quantity = array_key_exists('qty', $stock) ? $stock['qty'] : $stock['quantity'];
    $stock_status = isset($stock['is_in_stock']) ? (int) $stock['is_in_stock'] : 1;

    $changed = $this->updateStock($stock['sku'], $quantity, $stock_status);

    $this->logger->info('@operation stock for sku @sku. Message: @message', [
      '@operation' => $changed ? 'Updated' : 'Processed',
      '@sku' => $stock['sku'],
      '@message' => json_encode($stock),
    ]);
  }
1118033
public function createNew(StockItemInterface $item, UomQty $qty, Location $location,
        ?BatchInterface $batch = null): StockUnit
    {
        $code = $this->codeGenerator->generate($item, $qty, $location, $batch);

        return StockUnit::createDefault($code, $item, $qty, $location, $batch);
    }
7249
public function findAllBySku($sku)
    {

        // prepare the params
        $params = array(MemberNames::SKU => $sku);

        // initialize the array for the category product relations
        $categoryProducts = array();

        // load and return the product category relation for the passed product SKU
        $this->categoryProductsBySkuStmt->execute($params);

        // prepare the result by using the category ID as key
        foreach ($this->categoryProductsBySkuStmt->fetchAll(\PDO::FETCH_ASSOC) as $categoryProduct) {
            $categoryProducts[$categoryProduct[MemberNames::CATEGORY_ID]] = $categoryProduct;
        }

        // return the category product relations
        return $categoryProducts;
    }
475329
public function addCustomItem($name, $sku, $description, $price, $qty = 1)
    {
        $body = [
            'data' => [
                'type' => 'custom_item',
                'name' => $name,
                'sku' => $sku,
                'description' => $description,
                'quantity' => $qty,
                'price' => [
                    'amount' => $price
                ]
            ]
        ];
        return $this->call('POST', $body, $this->getReference() . '/items');
    }
933498
public function setSku($sku) {
        if(!$this->setModified('sku', $sku)->isModified()) {
            return $this;
        }
		$this->sku = $sku;
		return $this;
    }
903026
public function getLinkedskus($sku, $type = LINKED_SKU_TYPE_ALL) {
    // Without this we get following error:
    // 9006: Signature does not match expected signature.
    $sku = urlencode($sku);
    $endpoint = $this->apiVersion . "/agent/product/$sku/related/$type";

    $doReq = function ($client, $opt) use ($endpoint) {
      return ($client->get($endpoint, $opt));
    };

    $result = [];

    try {
      $result = $this->tryAgentRequest($doReq, 'linkedSkus', 'related');
    }
    catch (ConnectorException $e) {
      throw new RouteException(__FUNCTION__, $e->getMessage(), $e->getCode(), $this->getRouteEvents());
    }

    return $result;
  }
328860
public function getViewParameter($sKey)
    {
        return (isset($this->_aViewParams[$sKey])) ? $this->_aViewParams[$sKey] : \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter($sKey);
    }
1303966
public function removeOrphanPromotionFromSku(SKU $sku, int $nid) {
    $promotion_detach_item[] = ['target_id' => $nid];
    $sku_promotions = $sku->get('field_acm_sku_promotions')->getValue();
    $sku_promotions = array_udiff($sku_promotions, $promotion_detach_item, function ($array1, $array2) {
      return $array1['target_id'] - $array2['target_id'];
    });
    $sku->get('field_acm_sku_promotions')->setValue($sku_promotions);
    $sku->save();
    // Update Sku Translations.
    $translation_languages = $sku->getTranslationLanguages(TRUE);
    if (!empty($translation_languages)) {
      foreach ($translation_languages as $langcode => $language) {
        $sku_entity_translation = $sku->getTranslation($langcode);
        $sku_entity_translation->get('field_acm_sku_promotions')->setValue($sku_promotions);
        $sku_entity_translation->save();
      }
    }
  }
492900
public function addProductStock($productId, $quantity, array $skuInfo = null)
    {
        $result = $this->httpRaw(self::WECHAT_SHOP_PRODUCT_STOCK_ADD_URL . 'access_token=' . $this->getAccessToken(), [
            'product_id' => $productId,
            'quantity' => $quantity,
            'sku_info' => $skuInfo === null ? $skuInfo : implode(':', $skuInfo)
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success';
    }