Configuring Automatic Product Ordering from Suppliers in 1C-Bitrix
Automatic ordering from suppliers — when product stock falls below threshold, system creates purchase order without manager involvement. Requires: threshold values for each product, product-to-supplier binding, order creation and sending mechanism. Built on top of standard Bitrix modules.
Setting threshold values
Reorder threshold set for each product. Two storage options:
Option 1: infoblock custom properties — REORDER_POINT (quantity to order) and REORDER_QTY (how much to order). Set in product card in admin.
Option 2: separate bl_reorder_settings table with product_id, reorder_point, reorder_qty, supplier_id fields. Allows storing multiple suppliers per product with priorities.
For automatic threshold calculation use demand forecast from bl_sales_forecast: reorder_point = avg_daily_sales × lead_time_days × 1.2 (20% safety stock).
Stock monitoring agent
function AutoReorderAgent(): string
{
$db = \Bitrix\Main\Application::getConnection();
// Products below reorder threshold
$result = $db->query("
SELECT
rs.product_id,
rs.reorder_qty,
rs.supplier_id,
SUM(sp.AMOUNT) AS current_stock
FROM bl_reorder_settings rs
LEFT JOIN b_catalog_store_product sp ON sp.PRODUCT_ID = rs.product_id
WHERE rs.active = 1
GROUP BY rs.product_id, rs.reorder_qty, rs.supplier_id
HAVING current_stock < rs.reorder_point
AND NOT EXISTS (
SELECT 1 FROM bl_supplier_orders so
WHERE so.product_id = rs.product_id
AND so.status IN ('pending', 'sent', 'confirmed')
)
");
while ($row = $result->fetch()) {
SupplierOrderService::create(
$row['supplier_id'],
$row['product_id'],
$row['reorder_qty']
);
}
return 'AutoReorderAgent();';
}
NOT EXISTS condition prevents duplication — don't create new order if active one exists.
Sending order to supplier
SupplierOrderService::create() creates record in bl_supplier_orders and sends order via method configured for supplier:
-
Email: forms PDF or Excel with items via
\PHPExcelor standard Bitrix templates -
API: HTTP request to supplier endpoint via
\Bitrix\Main\Web\HttpClient - EDI: forms ORDERS message in EDIFACT/XML format and sends to FTP or API
class SupplierOrderService
{
public static function create(int $supplierId, int $productId, float $qty): void
{
$orderId = SupplierOrderTable::add([
'SUPPLIER_ID' => $supplierId,
'PRODUCT_ID' => $productId,
'QTY' => $qty,
'STATUS' => 'pending',
'CREATED_AT' => new \Bitrix\Main\Type\DateTime(),
])->getId();
$supplier = SupplierTable::getById($supplierId)->fetch();
match($supplier['ORDER_METHOD']) {
'api' => self::sendViaApi($supplier, $orderId, $productId, $qty),
'email' => self::sendViaEmail($supplier, $orderId, $productId, $qty),
'edi' => self::sendViaEdi($supplier, $orderId, $productId, $qty),
};
SupplierOrderTable::update($orderId, ['STATUS' => 'sent']);
}
}
Receiving confirmation and product arrival
Supplier confirms order and specifies expected delivery date. If supplier has API with webhooks — update status automatically. Otherwise — manager manually updates status in admin.
On actual product arrival, manager creates receipt document via "Warehouse → Documents → Receipt" in b_catalog_store_document. This automatically increases stock in b_catalog_store_product.
What we configure
-
bl_reorder_settingsandbl_supplier_orderstables with needed statuses -
AutoReorderAgentwith stock vs threshold comparison logic -
SupplierOrderServiceclass with email, API, EDI adapters - Admin interface for viewing active supplier orders
- Manager notifications about created auto-orders and overdue confirmations







