F
F
Franked2018-11-12 08:30:25
1C-Bitrix
Franked, 2018-11-12 08:30:25

How to display the quantity of certain goods in a particular warehouse?

Good day!
Please help me figure it out, I spent the whole night fiddling with the task, but I couldn’t implement it, although I saw a lot of similar posts on the Internet and already tried everything, but for some reason it didn’t work out :(
In general, I have 3 warehouses. Also my cart is filled with 4 items.The task is to display the quantity of each item in the cart in each of the warehouses.Something
like this: Warehouse_#1 : - Item_#1:
Total stock #1 of these items #1: 1pc - Item_#2: Total stock #1 of these items #2: 3pcs - Item_#3: Total stock #1 of these items #3: 7pcs.



- Item_#4: Total stock #1 of these items #4: 0pcs.
Warehouse_#2:
- Product_#1: There are a total of 11 items in warehouse #2 of these products #1 .
- Item_#2: In total, there are 23 items in stock #2 of these items #2 .
- Product_No. 3: In total, there are 2 such products in warehouse No. 3: 2 pcs.
- Product_No. 4: In total, there are 31 items in warehouse No. 2 of such goods No. 4 .
I myself tried to do through requests:

CCatalogStoreProduct::GetList(array(), array("PRODUCT_ID" => $prod_id, , "STORE_ID" => $store_ID), false, false, array("SELECT" => "AMOUNT"));

As well as:
\Bitrix\Catalog\StoreProductTable::getList(array('filter' => array('=PRODUCT_ID' >= 12391, '=STORE_ID' >= 2))));

But for some reason they return bool(false) values ​​to me as a result. Except for the second request I described. The second returns at least something, some product is not from the basket. By the way, PRODUCT_ID' >= 12391 - it works in this scenario...
Please tell me what can be done? Maybe I'm submitting the wrong request, please correct me...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Gritsuk, 2018-11-12
@winer

I tried to use \Bitrix\Catalog\StoreProductTable::getList
Here is a table with data
Here is a query

CModule::IncludeModule("catalog");

$products = [537, 547];
$amount = \Bitrix\Catalog\StoreProductTable::getList([
  'filter' => [
    'PRODUCT_ID' => $products
  ]
])->fetchAll();

print_r($amount);

You have
'=PRODUCT_ID' >= 12391 in your query,
and this is:
('=PRODUCT_ID' >= 12391) === false
and as a result the filter takes the form
array(false, '=STORE_ID' >= 2)

A
Andrey Savrasov, 2018-11-12
@alcorn

You can use the following:

CModule::IncludeModule('catalog');
$arFilter = Array("PRODUCT_ID"=>array(94247,162284));
$rsStoreAmount = CCatalogStoreProduct::GetList(Array(),$arFilter,false,false,Array());
while($arStoreAmount = $rsStoreAmount->Fetch())
{
  echo "<pre>";
  print_r($arStoreAmount);
  echo "</pre>";
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question