Jump to content

[Free Module] Products on CMS pages (PrestaShop 1.7 / 1.6)


vekia
 Share

Recommended Posts

Hi Vekia,

Today I've bought official addon powerfulformgenerator from addons.prestashop.com.

 

When I'm trying to install this addon, it shows me error message, see attached screenshot.

 

Is there any way how to install official addon next to your module "products on cms page"?

 

Thanks for any advice.

yhaC61z.png

Edited by Rudolfo78 (see edit history)

Share this post


Link to post
Share on other sites

Hi Vekia,

Today I've bought official addon powerfulformgenerator from addons.prestashop.com.

 

When I'm trying to install this addon, it shows me error message, see attached screenshot.

 

Is there any way how to install official addon next to your module "products on cms page"?

 

Thanks for any advice.

yhaC61z.png

in this case you have to merge both overrides (override from cmsProducts + override from powerfulformgenerator)

this is the only one way to use these two modules together

Share this post


Link to post
Share on other sites

in this case you have to merge both overrides (override from cmsProducts + override from powerfulformgenerator)

this is the only one way to use these two modules together

Unfortunately, I have no coding skills. How could I achieve your task?

Share this post


Link to post
Share on other sites

Hey Vekia o/

Do you have any news about this question i asked long time ago? That would be nice.

Hi Vekia! Thank you for this awesome module :)

Listen, is there a chance to center align the products into the cms page? If so, can you tell me how to do that? I'd really appreciate the help :) Thanks in advance!

Edited by Nandos (see edit history)

Share this post


Link to post
Share on other sites

Hi Vekia,

could you please merge these two files for me?

<?php

/**
 * PrestaShop module created by VEKIA, a guy from official PrestaShop community ;-)
 *
 * @author    VEKIA https://www.prestashop.com/forums/user/132608-vekia/
 * @copyright 2010-2016 VEKIA
 * @license   This program is not free software and you can't resell and redistribute it
 *
 * CONTACT WITH DEVELOPER http://mypresta.eu
 * support@mypresta.eu
 */
class CmsController extends CmsControllerCore
{
    public function init()
    {
        if ($id_cms = (int)Tools::getValue('id_cms'))
        {
            $this->cms = new CMS($id_cms, $this->context->language->id, $this->context->shop->id);
        }
        elseif ($id_cms_category = (int)Tools::getValue('id_cms_category'))
        {
            $this->cms_category = new CMSCategory($id_cms_category, $this->context->language->id, $this->context->shop->id);
        }
        if (Configuration::get('PS_SSL_ENABLED') && Tools::getValue('content_only') && $id_cms && Validate::isLoadedObject($this->cms) && in_array($id_cms, array(
                (int)Configuration::get('PS_CONDITIONS_CMS_ID'),
                (int)Configuration::get('LEGAL_CMS_ID_REVOCATION')
            ))
        )
        {
            $this->ssl = true;
        }
        parent::init();
        $this->canonicalRedirection();
        if (Validate::isLoadedObject($this->cms))
        {
            $adtoken = Tools::getAdminToken('AdminCmsContent' . (int)Tab::getIdFromClassName('AdminCmsContent') . (int)Tools::getValue('id_employee'));
            if (!$this->cms->isAssociatedToShop() || !$this->cms->active && Tools::getValue('adtoken') != $adtoken)
            {
                header('HTTP/1.1 404 Not Found');
                header('Status: 404 Not Found');
            }
            else
            {
                $this->assignCase = 1;
            }
        }
        elseif (Validate::isLoadedObject($this->cms_category) && $this->cms_category->active)
        {
            $this->assignCase = 2;
        }
        else
        {
            header('HTTP/1.1 404 Not Found');
            header('Status: 404 Not Found');
        }
    }

    public function setMedia()
    {
        parent::setMedia();
        if ($this->assignCase == 1)
        {
            $this->addJS(_THEME_JS_DIR_ . 'cms.js');
        }
        $this->addCSS(_THEME_CSS_DIR_ . 'product_list.css');
        $this->addCSS(_THEME_CSS_DIR_ . 'cms.css');
        $this->addCSS(_PS_MODULE_DIR_ . 'cmsproducts/cmsproducts.css');
    }

    public function initContent()
    {
        parent::initContent();
        $parent_cat = new CMSCategory(1, $this->context->language->id);
        $this->context->smarty->assign('id_current_lang', $this->context->language->id);
        $this->context->smarty->assign('home_title', $parent_cat->name);
        $this->context->smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
        if ($this->assignCase == 1)
        {
            if (isset($this->cms->id_cms_category) && $this->cms->id_cms_category)
            {
                $path = Tools::getFullPath($this->cms->id_cms_category, $this->cms->meta_title, 'CMS');
            }
            elseif (isset($this->cms_category->meta_title))
            {
                $path = Tools::getFullPath(1, $this->cms_category->meta_title, 'CMS');
            }


            $this->cms->content = $this->returnContent($this->cms->content);

            $this->context->smarty->assign(array(
                'cms' => $this->cms,
                'content_only' => (int)Tools::getValue('content_only'),
                'path' => $path,
                'body_classes' => array(
                    $this->php_self . '-' . $this->cms->id,
                    $this->php_self . '-' . $this->cms->link_rewrite
                )
            ));
            if ($this->cms->indexation == 0)
            {
                $this->context->smarty->assign('nobots', true);
            }
        }
        elseif ($this->assignCase == 2)
        {
            $this->context->smarty->assign(array(
                'category' => $this->cms_category,
                //for backward compatibility
                'cms_category' => $this->cms_category,
                'sub_category' => $this->cms_category->getSubCategories($this->context->language->id),
                'cms_pages' => CMS::getCMSPages($this->context->language->id, (int)$this->cms_category->id, true, (int)$this->context->shop->id),
                'path' => ($this->cms_category->id !== 1) ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '',
                'body_classes' => array(
                    $this->php_self . '-' . $this->cms_category->id,
                    $this->php_self . '-' . $this->cms_category->link_rewrite
                )
            ));
        }
        $this->setTemplate(_PS_THEME_DIR_ . 'cms.tpl');
    }

    public static function getImagesByID($id_product, $limit = 0)
    {
        $id_image = Db::getInstance()->ExecuteS('SELECT `id_image` FROM `' . _DB_PREFIX_ . 'image` WHERE cover=1 AND `id_product` = ' . (int)$id_product . ' ORDER BY position ASC LIMIT 0, ' . (int)$limit);
        $toReturn = array();
        if (!$id_image)
        {
            return null;
        }
        else
        {
            foreach ($id_image as $image)
            {
                $toReturn[] = $id_product . '-' . $image['id_image'];
            }
        }
        return $toReturn;
    }

    public function returnProduct($id_product)
    {
        $explode[] = $id_product;
        foreach ($explode as $tproduct)
        {
            if ($tproduct != '')
            {
                $x = (array)new Product($tproduct, true, $this->context->language->id);
                $productss[$tproduct] = $x;
                $productss[$tproduct]['id_product'] = $tproduct;
                $image = self::getImagesByID($tproduct, 1);
                $picture = explode('-', $image[0]);
                $productss[$tproduct]['id_image'] = $picture[1];

            }
        }
        $products = Product::getProductsProperties($this->context->language->id, $productss);
        $this->context->smarty->assign('products', $products);
        $this->context->smarty->assign('feedtype', "cmsSingleProductFeed");
        $contents = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'cmsproducts/products.tpl');
        return $contents;
    }

    public function returnProducts($id_product)
    {
        $explode_products = explode(",", $id_product);
        foreach ($explode_products AS $idp)
        {
            $explode[] = $idp;
            foreach ($explode as $tproduct)
            {
                if ($tproduct != '')
                {
                    $x = (array)new Product($tproduct, true, $this->context->language->id);
                    $productss[$tproduct] = $x;
                    $productss[$tproduct]['id_product'] = $tproduct;
                    $image = self::getImagesByID($tproduct, 1);
                    $picture = explode('-', $image[0]);
                    $productss[$tproduct]['id_image'] = $picture[1];

                }
            }
        }
        $products = Product::getProductsProperties($this->context->language->id, $productss);
        $this->context->smarty->assign('products', $products);
        $this->context->smarty->assign('feedtype', "cmsProductsFeed");
        $contents = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'cmsproducts/products.tpl');
        return $contents;
    }

    public function returnProductsHpp($block)
    {
        if (class_exists("Hpp"))
        {
            $hpp = new Hpp();
            if (method_exists($hpp, 'returnProducts'))
            {
                return $this->displayHpp($hpp->returnProducts($block));
            }
            else
            {
                return $this->noModuleMessage("Homepage Products Pro");
            }
        }
        else
        {
            return $this->noModuleMessage("Homepage Products Pro");
        }
    }

    public function returnProductsRpp($block)
    {
        if (class_exists("Ppb"))
        {
            $rpp = new Ppb();
            if (method_exists($rpp, 'returnProducts'))
            {
                return $this->displayRpp($rpp->returnProducts($block));
            }
            else
            {
                return $this->noModuleMessage("Related Products Pro");
            }
        }
        else
        {
            return $this->noModuleMessage("Related Products Pro");
        }
    }

    public function displayRpp($products)
    {
        if (count($products) <= 0)
        {
            $this->context->smarty->assign('feedtype', "noProducts");
        }
        else
        {
            $this->context->smarty->assign('products', $products);
            $this->context->smarty->assign('feedtype', "rppfeed");
        }
        $contents = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'cmsproducts/products.tpl');
        return $contents;
    }

    public function displayHpp($products)
    {
        if (count($products) <= 0)
        {
            $this->context->smarty->assign('feedtype', "noProducts");
        }
        else
        {
            $this->context->smarty->assign('products', $products);
            $this->context->smarty->assign('feedtype', "hppfeed");
        }
        $contents = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'cmsproducts/products.tpl');
        return $contents;
    }

    public function noModuleMessage($module)
    {
        $this->context->smarty->assign('products', $products);
        $this->context->smarty->assign('module', $module);
        $this->context->smarty->assign('feedtype', "error");
        $contents = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'cmsproducts/products.tpl');
        return $contents;
    }

    public function returnContent($contents)
    {
        /** PRODUCTS **/
        preg_match_all('/\{products\:[(0-9\,)]+\}/i', $contents, $matches);
        foreach ($matches[0] as $index => $match)
        {
            $explode = explode(":", $match);
            $contents = str_replace($match, $this->returnProducts(str_replace("}", "", $explode[1])), $contents);
        }

        /** PRODUCT **/
        preg_match_all('/\{product\:[(0-9\,)]+\}/i', $contents, $matches);
        foreach ($matches[0] as $index => $match)
        {
            $explode = explode(":", $match);
            $contents = str_replace($match, $this->returnProduct(str_replace("}", "", $explode[1])), $contents);
        }

        /** HOMEPAGE PRODUCTS PRO FEED **/
        preg_match_all('/\{hpp\:[(0-9)]+\}/i', $contents, $matches);
        foreach ($matches[0] as $index => $match)
        {
            $explode = explode(":", $match);
            $contents = str_replace($match, $this->returnProductsHpp(str_replace("}", "", $explode[1])), $contents);
        }

        /** RELATED PRODUCTS PRO FEED **/
        preg_match_all('/\{rpp\:[(0-9)]+\}/i', $contents, $matches);
        foreach ($matches[0] as $index => $match)
        {
            $explode = explode(":", $match);
            $contents = str_replace($match, $this->returnProductsRpp(str_replace("}", "", $explode[1])), $contents);
        }

        return $contents;
    }
}

and this one:

<?php
/**
 * Powerful Form Generator
 *
 * This modules aims to provide for your customer any kind of form you want.
 *
 * If you find errors, bugs or if you want to share some improvments,
 * feel free to contact at contact@prestaddons.net ! 
 * Si vous trouvez des erreurs, des bugs ou si vous souhaitez
 * tout simplement partager un conseil ou une amélioration,
 * n'hésitez pas à me contacter à contact@prestaddons.net
 *
 * @package   modules
 * @author    Cyril Nicodème <contact@prestaddons.net>
 * @copyright Copyright (C) April 2014 prestaddons.net <@email:contact@prestaddons.net>. All rights reserved.
 * @since     2014-04-15
 * @version   2.7.2
 * @license   Nicodème Cyril
 */
require_once(_PS_MODULE_DIR_.'powerfulformgenerator/classes/PFGRenderer.php');
class CmsController extends CmsControllerCore
{
    /*
	* module: powerfulformgenerator
	* date: 2017-04-21 20:54:49
	* version: 2.7.2
	*/
	public function initContent()
    {
        parent::initContent();
        $parent_cat = new CMSCategory(1, $this->context->language->id);
        $this->context->smarty->assign('id_current_lang', $this->context->language->id);
        $this->context->smarty->assign('home_title', $parent_cat->name);
        $this->context->smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
        if ($this->assignCase == 1) {
            if ($this->cms->indexation == 0) {
                $this->context->smarty->assign('nobots', true);
            }
            if (version_compare(Tools::substr(_PS_VERSION_, 0, 3), '1.7', '>=')) {
                $currentCms = $this->objectPresenter->present($this->cms);
                $currentCms['content'] = $this->returnContent($currentCms['content']);
                $this->context->smarty->assign(array(
                    'cms' => $currentCms,
                ));
                $this->setTemplate(
                    'cms/page',
                    array('entity' => 'cms', 'id' => $this->cms->id)
                );
            } else {
                if (isset($this->cms->id_cms_category) && $this->cms->id_cms_category) {
                    $path = Tools::getFullPath($this->cms->id_cms_category, $this->cms->meta_title, 'CMS');
                } elseif (isset($this->cms_category->meta_title)) {
                    $path = Tools::getFullPath(1, $this->cms_category->meta_title, 'CMS');
                }
                $this->cms->content = $this->returnContent($this->cms->content);
                $this->context->smarty->assign(array(
                    'cms' => $this->cms,
                    'content_only' => (int)Tools::getValue('content_only'),
                    'path' => $path,
                    'body_classes' => array($this->php_self.'-'.$this->cms->id, $this->php_self.'-'.$this->cms->link_rewrite)
                ));
                $this->setTemplate(_PS_THEME_DIR_.'cms.tpl');
            }
        } elseif ($this->assignCase == 2) {
            if (version_compare(Tools::substr(_PS_VERSION_, 0, 3), '1.7', '>=')) {
                $this->context->smarty->assign($this->getTemplateVarCategoryCms());
                $this->setTemplate('cms/category');
            } else {
                $this->context->smarty->assign(array(
                    'category' => $this->cms_category, //for backward compatibility
                    'cms_category' => $this->cms_category,
                    'sub_category' => $this->cms_category->getSubCategories($this->context->language->id),
                    'cms_pages' => CMS::getCMSPages($this->context->language->id, (int)$this->cms_category->id, true, (int)$this->context->shop->id),
                    'path' => ($this->cms_category->id !== 1) ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '',
                    'body_classes' => array($this->php_self.'-'.$this->cms_category->id, $this->php_self.'-'.$this->cms_category->link_rewrite)
                ));
                $this->setTemplate(_PS_THEME_DIR_.'cms.tpl');
            }
        }
    }
    /*
	* module: powerfulformgenerator
	* date: 2017-04-21 20:54:49
	* version: 2.7.2
	*/
	private function generatePFG($id_pfg)
    {
        $renderer = new PFGRenderer($id_pfg);
        if (!$renderer->isAllowed(true)) {
            $redirect_url = $renderer->getForm()->unauth_redirect_url[Context::getContext()->language->id];
            if (!empty($redirect_url)) {
                Tools::redirect($redirect_url);
            } else {
                Controller::getController('PageNotFoundController')->run();
            }
            exit();
        }
        return $renderer->displayForm();
    }
    /*
	* module: powerfulformgenerator
	* date: 2017-04-21 20:54:49
	* version: 2.7.2
	*/
	public function returnContent($contents)
    {
        preg_match_all('/\{powerfulform\:[(0-9\,)]+\}/i', $contents, $matches);
        foreach ($matches[0] as $index => $match) {
            $explode = explode(":", $match);
            $contents = str_replace($match, $this->generatePFG(str_replace("}", "", $explode[1])), $contents);
        }
        return $contents;
    }
}

Thank you very much!

Share this post


Link to post
Share on other sites

this should do the job: https://pastebin.com/wBQBUPSu

please check it and let me know if so.

 

before you will install cmsproducts you can empty its /override/ directory (or just remove cmsproducts/override directory)

Done, with your suggestion and result:

 

Module CMS Products works fine

Module Powerful Forms doesn't - blank page after using shortcode on CMS page

 

Any suggestions? Thank you...

 

Edit: ...after filling in some data in powerful form generator, it works fine as well! :)

 

Thank you Vekia, you are my Hero! :)

Edited by Rudolfo78 (see edit history)

Share this post


Link to post
Share on other sites

  • 4 weeks later...

Hi Vekia,

 

This module is potentially just what we are after. The module has installed fine but we are only seeing "{product:629}" as text on the cms page.

 

I have extended the text editors in the back-office following your previous post for tinymce which now accept javascript etc (which work well thanks). I presume this has something to with it!...

 

Your advice would be much appreciated - THANKS

Share this post


Link to post
Share on other sites

  • 1 month later...

Hi, Ive downloaded the Module but when I go to click the button to Install I get nothing. I acts like it looks then refreshes and still says install. Im currently in Presta 1.6.1.2

My site is FloorsUnlimited.com

 

Share this post


Link to post
Share on other sites

Hi, Ive downloaded the Module but when I go to click the button to Install I get nothing. I acts like it looks then refreshes and still says install. Im currently in Presta 1.6.1.2

My site is FloorsUnlimited.com

 

 

This topic has explanation of what is going on in such cases. 

this means that you've got an override of CMS controller and you will have to manually add override.

Share this post


Link to post
Share on other sites

Hi,

 

The module was working fine until i think last few days and suddenly everything just do not owrk.

Can i know what is the problem?

 

now it appear as coding instead of the product image

LOW ACID COFFEE

{products:1,2,11,12}

HEALTHY COFFEE

{products:3,9,10}

STRONG COFFEE

{products:4,39,40,41}

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Ok, i know it may be redundant, but if you have a ton of products you can actually use the category product listings.

 

What I mean by this is that you can edit the module so that it can accept the {categories} tag.

 

For instance, on a fresh PS 1.6.1.1 installation, you can add stuff like {categories: 1,2,3} whatever, and it shall display all products in those categories. In my case, my website has over 5000 products and i need to make a "special" tempalte for those who what to see a simplified version of the products list.

 

Provided you have the module up and running...

 

HOW TO ACHIEVE THIS:

 

In the CMSController override file, after:

public function returnProducts($id_product)
    {
        $explode_products = explode(",", $id_product);
        foreach ($explode_products AS $idp)
        {
            $explode[] = $idp;
            foreach ($explode as $tproduct)
            {
                if ($tproduct != '')
                {

                    $x = (array)new Product($tproduct, true, $this->context->language->id);
                    $productss[$tproduct] = $x;
                    $productss[$tproduct]['id_product'] = $tproduct;
                    $image = self::getImagesByID($tproduct, 1);
                    $picture = explode('-', $image[0]);
                    $productss[$tproduct]['id_image'] = $picture[1];

                }
            }
        }
        $products = Product::getProductsProperties($this->context->language->id, $productss);
        $this->context->smarty->assign('products', $products);
        $this->context->smarty->assign('feedtype', "cmsProductsFeed");
        $contents = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'cmsproducts/products.tpl');
        return $contents;
    }

You need to duplicate this function and rewrite it, like so:

//Display all products by category id
    public function returnCategoryProducts($id_category)
    {
        $explode_categories = explode(",", $id_category);
        foreach ($explode_categories as $idc)
        {
            $explode[] = $idc;
            foreach ($explode as $tcategories)
            {
                $categoryQuery = new Category($id_category);  //grab the category id from the tag
                if ($tcategories != '') {
                    foreach ($categoryQuery as $tcategorie) {  // loop in the category arrays
                        $categoryProducts = $categoryQuery->getProducts($this->context->language->id, 1, 100); //grab all the products associated with the specified category id
                        $products = Product::getProductsProperties($this->context->language->id, $categoryProducts);
                        $this->context->smarty->assign('products', $products);
                    }

                }
            }
        }

        $this->context->smarty->assign('feedtype', "cmsProductsFeed");
        $contents = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'cmsproducts/products.tpl');
        return $contents;
    }

Then, in the footer of the page, where you have: 

 public function returnContent($contents)
    {...

You need to duplicate the following function:

/** PRODUCTS **/
        preg_match_all('/\{products\:[(0-9\,)]+\}/i', $contents, $matches);
        foreach ($matches[0] as $index => $match)
        {
            $explode = explode(":", $match);
            $contents = str_replace($match, $this->returnProducts(str_replace("}", "", $explode[1])), $contents);
        }

Then simpliy do some minor adjustments and end up with:

/** CATEGORIES **/
        preg_match_all('/\{categories\:[(0-9\,)]+\}/i', $contents, $matches);
        foreach ($matches[0] as $index => $match)
        {
            $explode = explode(":", $match);
            $contents = str_replace($match, $this->returnCategoryProducts(str_replace("}", "", $explode[1])), $contents);   
        }

// replaced $this->returnProducts with $this->returnCategoryProducts
// and preg_match_all('/\{products\:[(0-9\,)]+\}/i', $contents, $matches); to preg_match_all('/\{categories\:[(0-9\,)]+\}/i', $contents, $matches);

Then go ahead and try it out. 

 

I'm building my website as a web version of Microsoft Excell, displaying products as spreadsheets.

 

Cheers!

  • Like 1

Share this post


Link to post
Share on other sites

Hello!

This addon is exactly what I was looking for

 

Just uploaded for PS 1.6.1.7..

After uploaded, i click on "install" button > pop-up ask me to continue > i accept -> BUT nothing happens.. no success message, no error message.. and it's not installed

Tried a lot of times, but nothing

 

Any idea about this issue?

Thanks a lot !

Share this post


Link to post
Share on other sites

Hi,

 

The module was working fine until i think last few days and suddenly everything just do not owrk.

Can i know what is the problem?

 

now it appear as coding instead of the product image

LOW ACID COFFEE

{products:1,2,11,12}

HEALTHY COFFEE

{products:3,9,10}

STRONG COFFEE

{products:4,39,40,41}

take a look on this:

https://mypresta.eu/documentation/global-resources/disabled-overrides-module-does-not-work.html

 

 

Hello!

This addon is exactly what I was looking for

 

Just uploaded for PS 1.6.1.7..

After uploaded, i click on "install" button > pop-up ask me to continue > i accept -> BUT nothing happens.. no success message, no error message.. and it's not installed

Tried a lot of times, but nothing

 

Any idea about this issue?

Thanks a lot !

 

i already explained whats up in such cases, somewhere in this topic. You already uses an override of CmsController so prestashop cant install the module. You have to:

- remove the module that applied current override CmsController (if you dont need module)

- combine two overrides into one (override from module you want to install with override from module that your shop already uses)

Share this post


Link to post
Share on other sites

Thanks Vekia,

 

Please is there any way how to make work this module inside module ph_simpleblog (which is free) ? Thanks :)

I need to shows products inside my POSTS, thanks ;)

Share this post


Link to post
Share on other sites

It's possible to center align the element added with this module? They always left align, no matter what. Let me know if possible, thanks.

 

with some css styles it should be possible.

can you share url to a cms page from your shop where you display the products?

  • Like 1

Share this post


Link to post
Share on other sites

  • 1 month later...
  • 2 weeks later...

Hi Vekia!

shop ver: 1.6.0.9.

modul ver:  1.5.1

The module works fine, but in error_log i got this :

"PHP Notice:  Undefined offset: 1 in  /override/controllers/front/CmsController.php on line 180"

would you help me please ?

 

 

This is the part of CmsController.php

"

public function returnProduct($id_product)
    {
        $explode[] = $id_product;
        foreach ($explode as $tproduct)
        {
            if ($tproduct != '')
            {
                $x = (array)new Product($tproduct, true, $this->context->language->id);
                $productss[$tproduct] = $x;
                $productss[$tproduct]['id_product'] = $tproduct;
                $image = self::getImagesByID($tproduct, 1);
                $picture = explode('-', $image[0]);
                $productss[$tproduct]['id_image'] = $picture[1];                      //This line was marked in error_log

            }
        }
        $products = Product::getProductsProperties($this->context->language->id, $productss);
        $this->context->smarty->assign('products', $products);
        $this->context->smarty->assign('feedtype', "cmsSingleProductFeed");
        $contents = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'cmsproducts/products.tpl');
        return $contents;
    }

"

Share this post


Link to post
Share on other sites

  • 3 months later...

Hello,

I added the shortcodes on the cms page but when i preview it shows me a syntax error in the Cmscontroller .php - unexpected ':'

I checked out the page and the error shows on this piece of repeating code: 

 {
            $explode = explode(":", $match);
            $contents = str_replace($match, $this->returnProducts(str_replace("}", "", $explode[1])), $contents);
        }

 

Any idea why is this happening?

Thanks.

Share this post


Link to post
Share on other sites

I updated the topic with recently released versions of the module

- added feature to support shortcode: {lastreviews}
- it displays recently added reviews from module: last product reviews
- added new shortcode {diff:2} that displays pictures comparison tool - a part of module before and after - picture comparison tool
- added improvements to problem with "missing" products in prestashop 1.7. If product does not exist - module does not generate internal server error anymore

 

Share this post


Link to post
Share on other sites

On 2/25/2018 at 2:44 PM, Ardi said:

Hello,

I added the shortcodes on the cms page but when i preview it shows me a syntax error in the Cmscontroller .php - unexpected ':'

I checked out the page and the error shows on this piece of repeating code: 

 {
            $explode = explode(":", $match);
            $contents = str_replace($match, $this->returnProducts(str_replace("}", "", $explode[1])), $contents);
        }

 

Any idea why is this happening?

Thanks.

 

may i ask for exact error code you see ?

Share this post


Link to post
Share on other sites

On 11/23/2017 at 11:43 AM, zavek said:

does not work with prestashop 1.6.0.14 version. cant even install it.

 

read the topic, your shop already uses an override or it is an issue with prestashop 1.6.0.14 (installation of modules)

Share this post


Link to post
Share on other sites

  • 3 months later...
On 24/7/2017 at 12:02 PM, vekia said:

 

with some css styles it should be possible.

can you share url to a cms page from your shop where you display the products?

 

Hello Vekia,

 

The same thing, how we can center the shortcode ? I center it, but always display it on the left side.

 

best regards

Share this post


Link to post
Share on other sites

hello

shortcode is replaced with product block. The design of block depends on your theme - usually it is a <div> with.

So in this case you need to use a code that will center a block (<div>) while text center is applicable to paraphraphs only (like <P> <span> etc.)

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hi Vekia, your module is great, i used it a lot...one thing that i would like if its possible is the following:
Instead of working with ID is it possible to work with REFERENCE field?

You are a true great developer.

My respect to you.

Share this post


Link to post
Share on other sites

On 8/10/2018 at 12:28 PM, ruisonika said:

Hi Vekia, your module is great, i used it a lot...one thing that i would like if its possible is the following:
Instead of working with ID is it possible to work with REFERENCE field?

You are a true great developer.

My respect to you.

 

currently module does not have this kind of feature, but i can implement it in the nearest future (next udpate)

Share this post


Link to post
Share on other sites

  • 1 month later...

Hi, this module "Prestashop Products on CMS pages" don't work on prestashop 1.7.4.2 ?

I'm building a localhost site and after installing this module, all my cms page crash down.. HTTP ERROR 500

Does anyone have solution plz ? I need this functionality.

Thx M8

 

Edit: Ok i had installing 1.6 addon on my prestashop 1.7  .... Sorry.

 

Edited by azer (see edit history)

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hello!

I have PS 1.7.3. and installation was success but I get error 500 when inserting shortcode to CMS page. When I take it off page works fine.

Any ideas?

PHP version: 7.1.22 / server: WHUK (Webhosting UK)

EDIT: works now... installed it again :)

Thanks for a great module Vekia!

Edited by MinnaLaa (see edit history)

Share this post


Link to post
Share on other sites

  • 4 weeks later...
En 13/10/2018 a las 1:58 PM, MinnaLaa dijo:

Hello!

I have PS 1.7.3. and installation was success but I get error 500 when inserting shortcode to CMS page. When I take it off page works fine.

Any ideas?

[...]

 

Hello @vekia!
I have the same issue in Prestashop 1.7.4.3

Server give this error:

AH01071: Got error 'PHP message: PHP Fatal error: Class 'ProductListingPresenter' not found in [...]/override/controllers/front/CmsController.php on line 120\n'

You Can see the file for line 120 here:
https://pastebin.com/CEncYuAR

As you can see is automatically merged with a PrettyURL module as I can see so that is not the problem ¿?

Any clue why give me the 500 error?

I also have your "CMS on homepage" and "HTMLbox" modules installed. You Rocks! =D
Fore sure I will check the rest of your modules shop =)

Best Regards

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hi Vekia

Thank you for this awesome module!

I installed it on my PS v1742. But had a problem when i wanted to activate it:
 

Quote

 

ERROR

L'action enable est impossible pour le module cmsproducts. Impossible d'installer la surcharge : La méthode initContent de la classe CmsController est déjà surchargée par le module gformbuilderpro version 1.1.1 au 2018-10-17 04:05:49 .

 

Indeed i do have gformbuilderpro on my PS and i can see that it already uses the method InitContent of the class CmsController...

Is there a trick for this?

Thank you very much.

Regards

Miran

Share this post


Link to post
Share on other sites

  • 1 month later...
  • 4 weeks later...
On 12/3/2018 at 11:43 AM, lemiran said:

Hi there

I saw that you said that we have to merge two overrides. But i don't really know how to realize that. A piece of help would be appreciated.

 

Thank you

Regards

Miran

i think you can solve without know how to merge by code 2 overrides with this plugin: https://addons.prestashop.com/en/administrative-tools/20250-multi-override.html

Share this post


Link to post
Share on other sites

  • 3 weeks later...

HI there,

the PS version that I am using is 1.6.1.23. The modules doesn't seems to work. It used to work and recently it doesn't work anymore.

what I see is 

{products:1,2,11,12}

HEALTHY COFFEE

{products:3,9,10}

Let me know where went wrong.

thanks,

Share this post


Link to post
Share on other sites

  • 8 months later...
On 3/17/2017 at 7:31 AM, Photon said:

In Yourtheme/js/global.js - line 42 of mine.


if (typeof page_name != 'undefined' && !in_array(page_name, ['index', 'product']))

add 'cms' in array to exclude :


if (typeof page_name != 'undefined' && !in_array(page_name, ['index', 'product','cms']))

And products will be displayed only in grid view in cms pages ;)

 

Hi community, I wonder if it is possible to allow larger space to product display so "LIST" view is possible in the module itself, then exclude CMS pages for GRID view ? Would be AWESOME !

Wishful thanks !

  • Like 1

Share this post


Link to post
Share on other sites

  • 3 weeks later...
  • 4 months later...

Hi,

How can I apply pagination for large number of products.

Is it possible to initially add 5 product from list of 50 product and on click of load more button list 5more product and so on.

 

Thansk,

Husein

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More