Jump to content

get product in custom module with prestashop 1.5


Recommended Posts

Hi.

I'm studying prestashop, i have pproblem with them.

I want to get total product with attribute visibility is everywhere or catalog only. then, i want show it in configuration page of mymodule.

Please help me!

Sorry for my english, and many thanks in advance!

Link to comment
Share on other sites

 

You mean you need the product list in your module's config page? Have you tried with Category::getProducts()?

I try it, but it didn't work.

$product = new Category();
		$product_total = $product->getProducts(1,0,0,'','',true,true,false,1,false);
		$this->context->smarty->assign(
				array(
						'id' => $product_total,
					)
			);
		return $this->display(__FILE__, 'testing.tpl');

but in .tpl file show 0, please give me some solution. thank in advance.

Edited by toanloau (see edit history)
Link to comment
Share on other sites

Parameters are totally wrong, have a look at the original scheme:

 

public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null)

 

You are passing a boolean to order way, and a  comma to order by. Also, $n should be a positive integer

Link to comment
Share on other sites

Parameters are totally wrong, have a look at the original scheme:

 

public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null)

 

You are passing a boolean to order way, and a  comma to order by. Also, $n should be a positive integer

Thank for your reply. it worked!

Link to comment
Share on other sites

×
×
  • Create New...