Jump to content

Product switch from grid to list gives "undefined" error


Recommended Posts

Hi, I'm using Prestashop 1.6.1.7. When I'm on my product page default as grid view. Everything is fine, but when I switch it to list view. I have the word "undefined" in my "right-block-content" div. 

 

Any help would be appreciated!

 

This usually happens due to some features being turned off. For example, if your theme originally shows color or any other combinations but they're turned off, you will get the undefined error. It could also be reviews, product description or anything else that's turned off. If it's not, then it must be because you have modified product-list.tpl. Did you perhaps comment out some lines in product-list.tpl? If you did, then you must do the same in global.js in your theme/js/ folder as list/table view is controlled by that .js file. Grid view is the default view, that's why if you comment out lines in product-list.tpl, it'll work fine but the .js file still has the original lines for list/table view. If it's not in global.js then look for it in your theme/js/ directory as it depends on the theme. Mine is in global.js.

  • Like 1
Link to comment
Share on other sites

 

It's either because the Add to cart button being disabled or the price. Go to /themes/theme1344/js/global.js. At line 243 you will find the following function:

var price = $(element).find('.content_price');  // check : catalog mode is enabled

Remove all these lines:

      var price = $(element).find('.content_price');  // check : catalog mode is enabled
      if (price != null) {
        html += price.clone().wrap('<div>').parent().html();
      }

At line 256, remove this line as well:

html += '<div class="button-container">' + $(element).find('.button-container').html() + '</div>';

Now we must do the same for grid view because when switching back to grid through jQuery, the code still executes. Remove code that begins at line 281:

      var price = $(element).find('.content_price');  // check : catalog mode is enabled
      if (price != null) {
        html += price.clone().wrap('<div>').parent().html();
      }

That's it. Save global.js and clear your cache if you don't have settings set to auto-recompile. See if it worked.

 

EDIT:

 

As @NemoPS stated below, it could also be hookReviews or availability as well. So if what I said didn't work, try removing the codes Nemo posted as well.

Edited by Masteries (see edit history)
Link to comment
Share on other sites

I suggest having a look at global.js.
it might be any of these

 

      var price = $(element).find('.content_price');  // check : catalog mode is enabled
      if (price != null) {
        html += price.clone().wrap('<div>').parent().html();
      }
      var hookReviews = $(element).find('.hook-reviews');
      if (hookReviews.length) {
        html += hookReviews.clone().wrap('<div>').parent().html();
      }
      var availability = $(element).find('.availability').html();  // check : catalog mode is enabled
      if (availability != null) {
        html += '<span class="availability">' + availability + '</span>';
      }

See the "display" method, it's the one responsible for the grid/list switch

Link to comment
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
×
×
  • Create New...