Jump to content

Edit History

Kelsier

Kelsier

Update:
 

I have ended up making a module, with a hook, which I call from a tpl. The hook works perfectly, it collects the products of the category, with all the information, including the specific prices. But I still have a problem, I can't get the variable to be passed to the tpl.

 

I am using the smarty->assing method but it doesn't work, in the tpl the variable returns null.

 

This is the code of my hook.

        if (array_key_exists('max', $params)) {
            $max = $params['max'];
        }
        else{
            $max = 1000;
        }

        $category = new Category(
            $params['id_category'], //id de la categoría
            (int)Context::getContext()->language->id // id del idioma
        );
        $caronteProducts = $category->getProducts(
            (int)Context::getContext()->language->id, //id lenguaje
             1, //número de páginas
             $max, //productos por páginas
             'date_add', //order by
             'DESC', //order way
             false, //get total
             true, //mostrar activos
             false, // random
             1, // random_number_products
             true, //check access
             Context::getContext() //context
        );
        $this->context->smarty->assign('caronteProducts', $caronteProducts);
        return $caronteProducts;

And so, that's how I call it from the tpl.

      {hook h="displayCaronteCategories" id_category=11}
      {$caronteProducts|var_dump}

However, when doing the var_dump from the tpl, the variable returns Null. From the hook the variable shows all the information.

image.png

Any help please?

 

Kelsier

Kelsier

Update:
 

I have ended up making a module, with a hook, which I call from a tpl. The hook works perfectly, it collects the products of the category, with all the information, including the specific prices. But I still have a problem, I can't get the variable to be passed to the tpl.

 

I am using the smarty->assing method but it doesn't work, in the tpl the variable returns null.

 

This is the code of my hook.

        if (array_key_exists('max', $params)) {
            $max = $params['max'];
        }
        else{
            $max = 1000;
        }

        $category = new Category(
            $params['id_category'], //id de la categoría
            (int)Context::getContext()->language->id // id del idioma
        );
        $caronteProducts = $category->getProducts(
            (int)Context::getContext()->language->id, //id lenguaje
             1, //número de páginas
             $max, //productos por páginas
             'date_add', //order by
             'DESC', //order way
             false, //get total
             true, //mostrar activos
             false, // random
             1, // random_number_products
             true, //check access
             Context::getContext() //context
        );
        $this->context->smarty->assign('caronteProducts', $caronteProducts);
        return $caronteProducts;

And so, that's how I call it from the tpl.

      {hook h="displayCaronteCategories" id_category=11}
      {$caronteProducts|var_dump}

However, when doing the var_dump from the tpl, the variable returns Null. From the hook the variable shows all the information.

 

Any help please?

 

image.png

Kelsier

Kelsier

Update:
 

I have ended up making a module, with a hook, which I call from a tpl. The hook works perfectly, it collects the products of the category, with all the information, including the specific prices. But I still have a problem, I can't get the variable to be passed to the tpl.

 

I am using the smarty->assing method but it doesn't work, in the tpl the variable returns null.

 

This is the code of my hook.

        if (array_key_exists('max', $params)) {
            $max = $params['max'];
        }
        else{
            $max = 1000;
        }

        $category = new Category(
            $params['id_category'], //id de la categoría
            (int)Context::getContext()->language->id // id del idioma
        );
        $caronteProducts = $category->getProducts(
            (int)Context::getContext()->language->id, //id lenguaje
             1, //número de páginas
             $max, //productos por páginas
             'date_add', //order by
             'DESC', //order way
             false, //get total
             true, //mostrar activos
             false, // random
             1, // random_number_products
             true, //check access
             Context::getContext() //context
        );
        $this->context->smarty->assign('caronteProducts', $caronteProducts);
        return $caronteProducts;

And so, that's how I call it from the tpl.

      {hook h="displayCaronteCategories" id_category=11}
      {$caronteProducts|var_dump}

However, when doing the var_dump from the tpl, the variable returns Null. From the hook the variable shows all the information.

Any help please?

 

×
×
  • Create New...