Jump to content

What can cause a hook not to be processed?


Recommended Posts

I'm still trying to work on getting the rating stars to appear in a category list. I'm basing the steps on the tutorial found here:

 

http://nemops.com/prestashop-product-rating-product-list/

 

I can get to step #3, but when I look at the categories in my store, the stars to do not appear.

 

I also looked in the database, and the hook isn't appearing there either.

 

So, for some reason, it's not even getting processed.

 

Is the hook name (ProductInList) case sensitive? Because I notice in Step #1, the "p" is lower case.

 

 

Link to comment
Share on other sites

Nemo:

 

Yes. The productInList appears in the Modules > Positions list! It's the last one.

 

post-636657-0-51548100-1378322511_thumb.png

 

But, for some reason, the stars do not appear.

 

 

 

Vekia:

 

I don't know how to do a {debug}. Do I need to do debug now that I've determined that the "productInList" hook appears in the Modules > Positions list?

Link to comment
Share on other sites

can you try adding

 

die('here I am)

 

at the beginning of the new hook function in productcomments.php?

 

At least you'll know if the hook as been loaded.

 

You can take that line down till it's not triggering anymore to try and find the issue

Link to comment
Share on other sites

Do you mean this function?

 

function hookProductInList($params)
{
    echo 'hey there';
}

 

So, with the line you recommended, should it look like this:

 

function hookProductInList($params)
{
    die('here i am')

    echo 'hey there';
}

 

 

You can take that line down till it's not triggering anymore to try and find the issue.

 

What does that mean?

Link to comment
Share on other sites

Let's just review what I've done so far. Perhaps you can tell me if I've done something wrong.

 

1) In the productcomments.php file (found in the modules/productcomments/ directory), I added the following at the top of the file (text in red is what I added):

 

public function install()
    {
        if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE))
            return false;
        else if (!$sql = file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE))
            return false;
        $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql);
        $sql = preg_split("/;\s*[\r\n]+/", trim($sql));

        foreach ($sql as $query)
            if (!Db::getInstance()->execute(trim($query)))
                return false;
        if (parent::install() == false ||
            !$this->registerHook('productTab') ||
            !$this->registerHook('extraProductComparison') ||
            !$this->registerHook('productTabContent') ||
            !$this->registerHook('header') ||
            !$this->registerHook('productOutOfStock') ||
            !$this->registerHook('productInList') ||
            !Configuration::updateValue('PRODUCT_COMMENTS_MINIMAL_TIME', 30) ||
            !Configuration::updateValue('PRODUCT_COMMENTS_ALLOW_GUESTS', 0) ||
            !Configuration::updateValue('PRODUCT_COMMENTS_MODERATE', 1))
                return false;
        return true;
    }

 

Then, at the bottom of the productcomments.php file, I added the following:

 

function hookProductInList($params)
{
    echo('hey there');
}

 

 

2) Then, in the product-list.tpl file (found in the themes/mytheme/ directory), I added the following:

 

<h3><a class="product_link" href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</a></h3>
            {hook h='productInList' idproduct=$product.id_product}

 

At this point the "hey there" should show up when I look at a category of products, right?

 

Did I miss anything?

Link to comment
Share on other sites

VEKIA:

 

I'm updating the following files, as per Nemo's tutorial:

 

1) productcomments.php (found in modules/productcomments directory), and

2) product-list.tpl (found in themes/mytheme directory)

 

Are these really the correct files that I need to be modifying, or are there others that I need to modify to get the result I want?

Link to comment
Share on other sites

Vekia:

 

Yes!

 

I do have a themes/mytheme/modules/productcomments directory.

 

But, within this directory, there are only .tpl files. The following files exist within this directory:

 

  • productcomments-extra.tpl
  • productcomments.tpl
  • productscomparison.tpl
  • tab.tpl

Should I look at making the changes that Nemo suggested in the productcomments.php file now in the productcomments.tpl file?

Link to comment
Share on other sites

I copied the default theme over to my server from my hard drive.

 

I then changed the theme within the admin panel to the default theme, and then when I looked at the site, it was a mess! It was a combination of the default theme and my purchased theme.

 

If I tried to look at a single product page, the page came up blank. So, right now I'm not going to waste time on the default theme. I don't want to use it anyway!

 

I still cannot get the stars to appear in a category listing on my theme.

 

Would purchasing a rating module, like the Google Rich Snippets + Product Ratings and Reviews, allow me to get the stars in a category listing? Or is this module just based on the Product Comments module?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...