Jump to content

Edit History

LabelGrup Networks

LabelGrup Networks

Si estás usando el tema Classic de Prestashop simplemente tendrías que ir al fichero  modules\ps_featuredproducts\ps_featuredproducts.php y modificar la siguiente función:

    protected function getProducts()
    {
        $category = new Category((int) Configuration::get('HOME_FEATURED_CAT')); //Aquí está la clave

        $searchProvider = new CategoryProductSearchProvider(
            $this->context->getTranslator(),
            $category
        );

        $context = new ProductSearchContext($this->context);

        $query = new ProductSearchQuery();

        $nProducts = Configuration::get('HOME_FEATURED_NBR');
        if ($nProducts < 0) {
            $nProducts = 12;
        }

        $query
            ->setResultsPerPage($nProducts)
            ->setPage(1)
        ;

        if (Configuration::get('HOME_FEATURED_RANDOMIZE')) {
            $query->setSortOrder(SortOrder::random());
        } else {
            $query->setSortOrder(new SortOrder('product', 'position', 'asc'));
        }

        $result = $searchProvider->runQuery(
            $context,
            $query
        );

        $assembler = new ProductAssembler($this->context);

        $presenterFactory = new ProductPresenterFactory($this->context);
        $presentationSettings = $presenterFactory->getPresentationSettings();
        $presenter = $presenterFactory->getPresenter();

        $products_for_template = [];

        foreach ($result->getProducts() as $rawProduct) {
            $products_for_template[] = $presenter->present(
                $presentationSettings,
                $assembler->assembleProduct($rawProduct),
                $this->context->language
            );
        }

        return $products_for_template;
    }

Tendrías que modificar la variable $category por la categoría que quieres mostrar, por ejemplo: 

$category = new Category(6);

Y con eso, en vez de mostrarte los productos destacados te mostraría los productos de la categoría que tu selecciones. Pero como te digo, eso en caso de usar el tema Classic.

 

Espero que sea esto lo que estuvieras buscando.

Saludos,

 

LabelGrup Networks

LabelGrup Networks

Si estás usando el tema Classic de Prestashop simplemente tendrías que ir a la clase ps_featuredproducts.php y modificar la siguiente función:

    protected function getProducts()
    {
        $category = new Category((int) Configuration::get('HOME_FEATURED_CAT')); //Aquí está la clave

        $searchProvider = new CategoryProductSearchProvider(
            $this->context->getTranslator(),
            $category
        );

        $context = new ProductSearchContext($this->context);

        $query = new ProductSearchQuery();

        $nProducts = Configuration::get('HOME_FEATURED_NBR');
        if ($nProducts < 0) {
            $nProducts = 12;
        }

        $query
            ->setResultsPerPage($nProducts)
            ->setPage(1)
        ;

        if (Configuration::get('HOME_FEATURED_RANDOMIZE')) {
            $query->setSortOrder(SortOrder::random());
        } else {
            $query->setSortOrder(new SortOrder('product', 'position', 'asc'));
        }

        $result = $searchProvider->runQuery(
            $context,
            $query
        );

        $assembler = new ProductAssembler($this->context);

        $presenterFactory = new ProductPresenterFactory($this->context);
        $presentationSettings = $presenterFactory->getPresentationSettings();
        $presenter = $presenterFactory->getPresenter();

        $products_for_template = [];

        foreach ($result->getProducts() as $rawProduct) {
            $products_for_template[] = $presenter->present(
                $presentationSettings,
                $assembler->assembleProduct($rawProduct),
                $this->context->language
            );
        }

        return $products_for_template;
    }

Tendrías que modificar la variable $category por la categoría que quieres mostrar, por ejemplo: 

$category = new Category(6);

Y con eso, en vez de mostrarte los productos destacados te mostraría los productos de la categoría que tu selecciones. Pero como te digo, eso en caso de usar el tema Classic.

 

Espero que sea esto lo que estuvieras buscando.

Saludos,

 

LabelGrup Networks

LabelGrup Networks

Si estás usando el tema Classic de Prestashop simplemente tendrías que ir a la clase ps_featuredproducts.php y modificar la siguiente función:

    protected function getProducts()
    {
        $category = new Category((int) Configuration::get('HOME_FEATURED_CAT')); //Aquí está la clave

        $searchProvider = new CategoryProductSearchProvider(
            $this->context->getTranslator(),
            $category
        );

        $context = new ProductSearchContext($this->context);

        $query = new ProductSearchQuery();

        $nProducts = Configuration::get('HOME_FEATURED_NBR');
        if ($nProducts < 0) {
            $nProducts = 12;
        }

        $query
            ->setResultsPerPage($nProducts)
            ->setPage(1)
        ;

        if (Configuration::get('HOME_FEATURED_RANDOMIZE')) {
            $query->setSortOrder(SortOrder::random());
        } else {
            $query->setSortOrder(new SortOrder('product', 'position', 'asc'));
        }

        $result = $searchProvider->runQuery(
            $context,
            $query
        );

        $assembler = new ProductAssembler($this->context);

        $presenterFactory = new ProductPresenterFactory($this->context);
        $presentationSettings = $presenterFactory->getPresentationSettings();
        $presenter = $presenterFactory->getPresenter();

        $products_for_template = [];

        foreach ($result->getProducts() as $rawProduct) {
            $products_for_template[] = $presenter->present(
                $presentationSettings,
                $assembler->assembleProduct($rawProduct),
                $this->context->language
            );
        }

        return $products_for_template;
    }

 

×
×
  • Create New...