SeiyaJapon
SeiyaJapon

Reputation: 564

prestashop 1.6 get all products

I want to get all products of my Prestashop 1.6.

Can someone learn me to get all products? Something like

    $products = Controller::getAllProducts();

or

    $products = Controller::getProducts();

And if this is not possible, how get products by category using a HTML select?

Upvotes: 1

Views: 4810

Answers (1)

marsaldev
marsaldev

Reputation: 3349

In your module or custom controller type:

$products = Product::getProducts($this->context->language->id, 1, 5000, 'name', 'ASC');

The prototype of getProducts() method is:

  /**
    * Get all available products
    *
    * @param int $id_lang Language id
    * @param int $start Start number
    * @param int $limit Number of products to return
    * @param string $order_by Field for ordering
    * @param string $order_way Way for ordering (ASC or DESC)
    * @return array Products details
    */
    public static function getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category = false, $only_active = false, Context $context = null)

Upvotes: 4

Related Questions