コード例 #1
0
// Loads the stock
$stock = new CProductStockService();
// If stock_id has been provided, we load the associated product
if ($stock_service_id) {
    $stock->load($stock_service_id);
    $stock->loadRefsFwd();
    $stock->_ref_product->loadRefsFwd();
} else {
    if ($product_id) {
        $product = new CProduct();
        $product->load($product_id);
        $stock->product_id = $product_id;
        $stock->_ref_product = $product;
        $stock->updateFormFields();
    } else {
        $stock->loadRefsFwd();
        // pour le _ref_product
    }
}
// Categories list
$list_categories = new CProductCategory();
$list_categories = $list_categories->loadList(null, 'name');
$list_services = CProductStockGroup::getServicesList();
// Création du template
$smarty = new CSmartyDP();
$smarty->assign('stock', $stock);
$smarty->assign('category_id', $category_id);
$smarty->assign('service_id', $service_id);
$smarty->assign('list_categories', $list_categories);
$smarty->assign('list_services', $list_services);
$smarty->display('vw_idx_stock_service.tpl');