Get stock item ID by product ID & stock ID.

@param int $prodId
@param int $stockId
@return int
763108
private function getStockItemId($prodId, $stockId)
    {
        $query = $this->qbGetStockItem->build();
        $conn = $query->getConnection();
        $bind = [
            OwnQbGetStockItem::BND_PROD_ID => $prodId,
            OwnQbGetStockItem::BND_STOCK_ID => $stockId
        ];
        $result = $conn->fetchOne($query, $bind);
        return $result;
    }
1351229
public function indexOf($itemID)
    {
        $cnt = parent::count();
        for ($i = 0; $i < $cnt; $i++) {
            if ($this->items[$i]->id == $itemID) {
                return $i;
            }
        }

        return -1;
    }
312289
public function addStockMovement(StockMovementInterface $stockMovement)
    {
        $this->initStockMovements();

        if ($this->stockMovements->count()) {
            /** @var StockMovement $firstStockMovement */
            $firstStockMovement = $this->stockMovements->first();
            if ($stockMovement->getProduct()->getId() !== $firstStockMovement->getProduct()->getId()) {
                throw new StockMovementProductMismatchException('The product id of the first product is `'.$firstStockMovement->getProduct()->getId().'` while the one you are adding has this id: `'.$stockMovement->getProduct()->getId().'`');
            }
        }

        if (!$this->stockMovements->contains($stockMovement)) {
            $this->stockMovements->add($stockMovement);
        }

        return $this;
    }
578453
public function getByStockItemId($stockItemId)
    {
        $where = Entity::A_STOCK_ITEM_REF . '=' . (int)$stockItemId;
        $result = $this->get($where);
        return $result;
    }
613895
protected function getProductIds( array $productItems )
	{
		$prodIds = [];

		foreach( $productItems as $product )
		{
			if( $product->getType() === 'select' ) {
				$prodIds = array_merge( $prodIds, array_keys( $product->getRefItems( 'product', 'default', 'default' ) ) );
			}
		}

		return $prodIds;
	}
675769
private function getServiceItemForMageItem(\Magento\Sales\Api\Data\OrderItemInterface $item, $stockId = null)
    {
        $result = new \Praxigento\Pv\Service\Sale\Data\Item();
        $prodId = $item->getProductId();
        $itemId = $item->getItemId();
        /* qty of the product can be changed in invoice but we use ordered only */
        $qty = $item->getQtyOrdered();
        /* create data item for service */
        $result->setItemId($itemId);
        $result->setProductId($prodId);
        $result->setQuantity($qty);
        $result->setStockId($stockId);
        return $result;
    }
947440
public function setProductId( $productid )
	{
		if ( $productid == $this->getProductId() ) { return; }

		$this->_values['ordprodid'] = (int) $productid;
		$this->setModified();
	}
1013358
public function loadById($productId)
    {
        return $this->productRepository->getById($productId, false, $this->storeManager->getStore()->getId(), true);
    }
570104
public function getProductPositions($categoryId, $storeId)
    {
        $select = $this->getBaseSelect()
            ->where('category_id = ?', (int) $categoryId)
            ->where('store_id = ?', (int) $storeId)
            ->where('position IS NOT NULL')
            ->columns(['product_id', 'position']);

        return $this->getConnection()->fetchPairs($select);
    }
1285727
public function product( $prodIds )
	{
		if( !empty( $prodIds ) && ( $ids = array_unique( $this->validateIds( (array) $prodIds ) ) ) !== [] ) {
			$this->conditions[] = $this->filter->compare( '==', 'product.id', $ids );
		}

		return $this;
	}
1088721
public function loadProducts($tid, $status = 1) {
    $loadProducts = &drupal_static(__FUNCTION__);
    if (!isset($loadProducts)) {
      $query = $this->connection->select('site_commerce_field_data', 'n');
      $query->fields('n', array('pid', 'title'));
      if ($status < 2) {
        $query->condition('n.status', $status);
      }
      $query->innerJoin('site_commerce__field_category', 't', 't.entity_id=n.pid');
      $query->condition('t.field_category_target_id', $tid);

      $loadProducts = $query->execute()->fetchAllKeyed();
    }
    return $loadProducts;
  }
795698
public function addData($storeId, array $indexData)
    {
        $inventoryData = $this->getResourceModel()->loadInventoryData($storeId, array_keys($indexData));

        foreach ($inventoryData as $inventoryDataRow) {
            $productId = (int) $inventoryDataRow['product_id'];
            $indexData[$productId]['stock'] = [
                'is_in_stock' => (bool) $inventoryDataRow['stock_status'],
                'qty'         => (int) $inventoryDataRow['qty'],
            ];
        }

        return $indexData;
    }
980317
public function getRelatedCompanyIdsByIdProductList(int $idProductList): array
    {
        /** @var \Orm\Zed\ProductList\Persistence\SpyProductListCompanyQuery $productListCompanyQuery */
        $productListCompanyQuery = $this->getFactory()
            ->createProductListCompanyQuery()
            ->select(SpyProductListCompanyTableMap::COL_FK_COMPANY);

        return $productListCompanyQuery
            ->findByFkProductList($idProductList)
            ->toArray();
    }
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';
    }
1216557
public function getItemByID($id)
    {
        $item = current(array_filter($this->items, function (Item $item) use ($id) {
            return ($item->id === $id);
        }));

        return ($item) ? $item : null;
    }
1018674
public function getProductCategoryIds()
    {

        // initialize the array with the product's category IDs
        $categoryIds = array();

        // query whether or not category IDs are available for the actual product entity
        if (isset($this->productCategoryIds[$lastEntityId = $this->getLastEntityId()])) {
            $categoryIds = $this->productCategoryIds[$lastEntityId];
        }

        // return the array with the product's category IDs
        return $categoryIds;
    }
12719
protected function getRemoveCategoryArticlesQueryFilter($categoryID, $prodIds)
    {
        $db = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $where = "where oxcatnid=" . $db->quote($categoryID);

        $whereProductIdIn = " oxobjectid in ( {$prodIds} )";
        if (!\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blVariantsSelection')) {
            $whereProductIdIn = "( " . $whereProductIdIn . " OR oxobjectid in (
                                        select oxid from oxarticles where oxparentid in ({$prodIds})
                                        )
            )";
        }
        $where = $where . ' AND ' . $whereProductIdIn;

        return $where;
    }