Esempio n. 1
0
// Loads the required Product and its References
$product = new CProduct();
if ($product->load($product_id)) {
    $product->loadRefsBack();
    $endowment_item = new CProductEndowmentItem();
    $ljoin = array('product_endowment' => "product_endowment.endowment_id = product_endowment_item.endowment_id");
    foreach ($product->_ref_stocks_service as $_stock) {
        $where = array("product_endowment.service_id" => "= '{$_stock->object_id}'", "product_endowment_item.product_id" => "= '{$product->_id}'");
        $_stock->_ref_endowment_items = $endowment_item->loadList($where, null, null, null, $ljoin);
    }
    foreach ($product->_ref_references as $_reference) {
        $_reference->loadRefProduct();
        $_reference->loadRefSociete();
    }
    $product->loadRefStock();
    $where = array("stock_class" => " = 'CProductStockGroup'", "stock_id" => " = '{$product->_ref_stock_group->stock_id}'");
    $delivery = new CProductDelivery();
    $product->_ref_deliveries = $delivery->loadList($where, "date_dispensation DESC, date_delivery DESC", 50);
    foreach ($product->_ref_deliveries as $_delivery) {
        $_delivery->loadRefsBack();
    }
    $product->loadView();
}
// Loads the required Category the complete list
$category = new CProductCategory();
$list_categories = $category->loadList(null, 'name');
// Smarty template
$smarty = new CSmartyDP();
$smarty->assign('product', $product);
$smarty->assign('list_categories', $list_categories);
$smarty->display('inc_edit_product.tpl');