Jump to content

How to make a choice of the products in my module  settings  prestashop 1.6.?


Recommended Posts

Hello!
How to make a choice of the products in my module  settings  prestashop 1.6.?)
Unfortunately, I could not find instructions on this subject.
I need a list of products inside my module, where I can delete or add products, which I will then display on the main page.

Link to comment
Share on other sites

https://doc.prestashop.com/display/PS16/Using+the+HelperList+class

https://doc.prestashop.com/display/PS16/Using+the+HelperForm+class

https://doc.prestashop.com/display/PS16/Using+the+HelperOptions+class

https://doc.prestashop.com/display/PS16/Developer+tutorials

 

If you need to create a list, you will always find the necessary functions in classes / *. *

Open eg ./classes/Product.php

Find function getProducts();

In the module you will use the name class and function to fill your list.
For example?

public function myProductList()
{
	$id_lang = '1';
	$start = '0';
	$limit = '100';
	$order_by = 'name';
	$order_way = 'ASC';
	$id_category = false;
	$only_active = true;
	$getProducts = Product::getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category, $only_active);

	$fields_list = array(
    	'id_product' => array(
        	'title' => $this->l('id'), 
            'type'  => 'text',
            'class' => 'fixed-width-xs',
            'search' => true,  
            'orderby' => false,
            'visible' => true 
        ),
		'name' => array(
            'title' => $this->l('name'),
            'type' => 'text',
            'inline' => true,
            'search' => false,
            'orderby' => true,
        ),
	);

    $helper = new HelperList();
    $helper->shopLinkType = '';
    $helper->no_link = true;       
    $helper->simple_header = false; 
    $helper->show_toolbar = true;
    $helper->actions = array('edit', 'delete');
    $helper->module = $this;
    $helper->listTotal = count($getProducts);
    $helper->_default_pagination = 100;
    $helper->toolbar_scroll = false;
    $helper->identifier = 'id_product';
    $helper->title = $this->l('Product list');
    $helper->table = 'product';
    $helper->token = Tools::getAdminTokenLite('AdminModules');
    $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
        
    return $helper->generateList($getProducts, $fields_list);

}

 

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

 

And how to make a drop-down list in the field so that when you enter the name of the product it is pulled up, is there a solution from prestashop or do you need to do custom?

I am making a module that displays only the products I have selected on the main page.

image.png

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...