Jump to content

Quantità Prodotto Sempre A Zero...


dpmika

Recommended Posts

Ciao a tutti, 

 

ho creato un semplice modulo che mi visualizza i prodotti in homepage, ho utilizzato la classe products per estrarre i prodotti dal db.

 

L'unico problema che riscontro è che nonostante abbia inserito 50 pezzi del prodotto, la quantità del prodotto rimane a zero.

 

  //Prelevo prodotti
    $productObj = new Product();
    $products = $productObj -> getProducts(1, 0, 10, 'id_product', 'DESC', false, true);

cosi prelevo i prodotti e come risposta ho:

Array ( [0] => Array ( [prodotto] => Array ( [id_product] => 1 [id_supplier] => 0 [id_manufacturer] => 0 [id_category_default] => 2 [id_shop_default] => 1 [id_tax_rules_group] => 1 [on_sale] => 0 [online_only] => 0 [ean13] => [upc] => [ecotax] => 0.000000 [quantity] => 0 [minimal_quantity] => 1 [price] => 37.000000 [wholesale_price] => 27.450000 [unity] => [unit_price_ratio] => 0.000000 [additional_shipping_cost] => 0.00 [reference] => 6050341 [supplier_reference] => [location] => [width] => 0.000000 [height] => 0.000000 [depth] => 0.000000 [weight] => 0.000000 [out_of_stock] => 2 [quantity_discount] => 0 [customizable] => 0 [uploadable_files] => 0 [text_fields] => 0 [active] => 1 [redirect_type] => 404 [id_product_redirected] => 0 [available_for_order] => 1 [available_date] => 0000-00-00 [condition] => new [show_price] => 1 [indexed] => 1 [visibility] => both [cache_is_pack] => 0 [cache_has_attachments] => 0 [is_virtual] => 0 [cache_default_attribute] => 0 [date_add] => 2015-12-07 10:00:00 [date_upd] => 2015-12-07 10:31:06 [advanced_stock_management] => 0 [pack_stock_type] => 3 [id_shop] => 1 [id_lang] => 1 [description] => [description_short] => [link_rewrite] => 50 [meta_description] => [meta_keywords] => [meta_title] => [name] => 50 [available_now] => [available_later] => [manufacturer_name] => [supplier_name] => [rate] => 22 [tax_name] => IVA IT 22% ) [image_url] => http://localhost/bot/shop/img/p/1/1.jpg ) )

come detto, anche se ho inserito 50 pezzi disponibili, la quantità mi risulta 0.

 

qualcuno sa il perche?

 

Link to comment
Share on other sites

Non credo sia un problema del modulo anche perchè per prelevare i prodotti dal db uso la classe Product, nativa di prestashop:

//Prelevo prodotti
    $productObj = new Product();
    $products = $productObj -> getProducts(1, 0, 10, 'id_product', 'DESC', false, true);

e questo è quello che mi restituisce:

Array ( [0] => Array ( [prodotto] => Array ( [id_product] => 1 [id_supplier] => 0 [id_manufacturer] => 0 [id_category_default] => 2 [id_shop_default] => 1 [id_tax_rules_group] => 1 [on_sale] => 0 [online_only] => 0 [ean13] => [upc] => [ecotax] => 0.000000 [quantity] => 0 [minimal_quantity] => 1 [price] => 37.000000 [wholesale_price] => 27.450000 [unity] => [unit_price_ratio] => 0.000000 [additional_shipping_cost] => 0.00 [reference] => 6050341 [supplier_reference] => [location] => [width] => 0.000000 [height] => 0.000000 [depth] => 0.000000 [weight] => 0.000000 [out_of_stock] => 2 [quantity_discount] => 0 [customizable] => 0 [uploadable_files] => 0 [text_fields] => 0 [active] => 1 [redirect_type] => 404 [id_product_redirected] => 0 [available_for_order] => 1 [available_date] => 0000-00-00 [condition] => new [show_price] => 1 [indexed] => 1 [visibility] => both [cache_is_pack] => 0 [cache_has_attachments] => 0 [is_virtual] => 0 [cache_default_attribute] => 0 [date_add] => 2015-12-07 10:00:00 [date_upd] => 2015-12-07 10:31:06 [advanced_stock_management] => 0 [pack_stock_type] => 3 [id_shop] => 1 [id_lang] => 1 [description] => [description_short] => [link_rewrite] => 50 [meta_description] => [meta_keywords] => [meta_title] => [name] => 50 [available_now] => [available_later] => [manufacturer_name] => [supplier_name] => [rate] => 22 [tax_name] => IVA IT 22% ) [image_url] => http://localhost/bot/shop/img/p/1/1.jpg ) )

come si può notare sul nodo quantity il valore è zero, nonostante abbiamo modificato i quantitativi dei prodotti.

 

Forse prestashop utilizza un altra tabella per le quantità  dei prodotti e quindi questa classe che sto utilizzando è deprecata ?

Link to comment
Share on other sites

Forse ci sono, controllando la tabella dei prodotti effettivamente le quantità sono a 0.

 

Per prelevare la quantità dei prodotti devo utilizzare il metodo sempre dalla classe product:

function getQuantity($id_product, $id_product_attribute = null, $cache_is_pack = null)

Questo metodo preleva le quantità dalla tabella ps_stock_available anzichè da ps_products.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...