簡體   English   中英

Prestashop - 字段“數量”已棄用

[英]Prestashop - Field 'quantity' is deprecated

我需要顯示數量,但是當我實現它時,它告訴我該字段已過時,我不明白錯誤

我的代碼:

$id_lang = (int)Context::getContext()->language->id;
$start = 0;
$limit = 100;
$order_by = 'id_product';
$order_way = 'DESC';
$all_products = Product::getProducts($id_lang, $start, $limit, $order_by, $order_way);
foreach ($all_products as $products) {
    $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('product', 'product');
    $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('id', 'id');
    $this->output .= $products['id_product'];
    $this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('id', '/id');
    $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('id_category_default ', 'id_category_default ');
    $this->output .= $products['id_category_default'];
    $this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('id_category_default ', '/id_category_default ');
    $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('name', 'name');
    $this->output .= $products['name'];
    $this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('name', '/name');
    $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('price', 'price');
    $this->output .= $products['price'];
    $this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('price', '/price');
    $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('description', 'description');
    $this->output .= $products['description'];
    $this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('description', '/description');
    $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('quantity', 'quantity');
    $this->output .= $products['quantity'];
    $this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('quantity', '/quantity');
    $this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('product', '/product');
}

感謝你們對我的幫助

product 中的 Quantity 字段長期以來已被棄用,為了檢索產品庫存,您應該使用靜態方法:

StockAvailable::getQuantityAvailableByProduct($idProduct, $idProductAttribute));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM