VirtueMart 3.0.18.6 Category product display error

GK User
Thu Dec 15, 2016 3:13 pm
Hi, a few days ago I was forced to upgrade to VM 3.0.18.6 because of child products creation bug. So far so good until I realized that all category details views (the one that displays the actual products from a category) where broken with this error message:
PHP Fatal error: Call to a member function displayMediaThumb() on null in /public_html/templates/gk_storefront/html/com_virtuemart/category/default.php on line 230

The issue arises because for some reason, VM devs have changed the way the "Products" property of the view gets loaded, so, to fix this you have to change in templates/gk_storefront/html/com_virtuemart/category/default.php
After defined('_JEXEC') or die('Restricted access'); add this:
Code: Select all
if(vRequest::getInt('dynamic')){
   if (!empty($this->products)) {
      if($this->fallback){
         $p = $this->products;
         $this->products = array();
         $this->products[0] = $p;
         vmdebug('Refallback');
      }

      echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));

   }

   return ;
}


Search for
Code: Select all
$BrowseTotalProducts = count($this->products);

and chagne it to
Code: Select all
$BrowseTotalProducts = count($this->products[0]);


After
Code: Select all
<div class="browse-view">
<?php
   // Show child categories
   if (!empty($this->products)) {


Change it to
Code: Select all
<div class="browse-view">
<?php
   // Show child categories
   if (!empty($this->products)) {
      //revert of the fallback in the view.html.php, will be removed vm3.2
      if($this->fallback){
         $p = $this->products;
         $this->products = array();
         $this->products[0] = $p;
         vmdebug('Refallback');
      }

      $BrowseTotalProducts = count($this->products[0]);


For some reason VM devs have loaded all products on the "0" array element of the products view property. Strange, but doing the above solves it!
User avatar
Expert Boarder

teitbite
Tue Dec 20, 2016 5:42 pm
Hi

Thank You for that. Will pass it to programmers.
User avatar
Moderator

teitbite
Wed Dec 21, 2016 2:44 pm
Hi

I've passed this to programmers, but they told me there was no problem in category layout even without Your changes. Are You sure You have been using latest VM and template ? What PHP version are You using ?
User avatar
Moderator

GK User
Wed Dec 21, 2016 6:15 pm
Latest VM and template that's for shure! because I had have to upgrade my site because an issue of VM and child products creation, that forced me to upgrade the template as well...

PHP ver is 5.6.28
User avatar
Expert Boarder

teitbite
Wed Dec 21, 2016 6:50 pm
Hi

Ok. Thank You will pass this to programmers.
User avatar
Moderator

GK User
Thu Dec 22, 2016 12:09 pm
Hi, I'm using storebox template and having the same problem (using php 7.0.13, switching to 5.6 gives simply a error 500), so I tried to apply your modifications, but I'm getting
Code: Select all
syntax error, unexpected '<'
It appears the page you were looking for doesn't exist. Sorry about that.

It depends for sure on the child categories code being a tad different
Code: Select all
<div class="browse-view">
   <?php
   // Show child categories
   if (!empty($this->products)) : ?>

I tried adding a ?> to close the php, but now I get
Code: Select all
syntax error, unexpected 'elseif' (T_ELSEIF)
It appears the page you were looking for doesn't exist. Sorry about that.

I hope you can help me, for sure it will be useful to many other users.
If you want to have a look, this is the code of my default.php (just gavick's last code with your suggestions applied)
Code: Select all
<?php
/**
*
* Show the products in a category
*
* @package   VirtueMart
* @subpackage
* @author RolandD
* @author Max Milbers
* @todo add pagination
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 5120 2011-12-18 18:29:26Z electrocity $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

if(vRequest::getInt('dynamic')){
   if (!empty($this->products)) {
      if($this->fallback){
         $p = $this->products;
         $this->products = array();
         $this->products[0] = $p;
         vmdebug('Refallback');
      }

      echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));

   }

   return ;
}

/* javascript for list Slide
  Only here for the order list
  can be changed by the template maker */
$js = "jQuery(document).ready(function () {
   jQuery('.orderlistcontainer').hover(
      function() { jQuery(this).find('.orderlist').stop().show()},
      function() { jQuery(this).find('.orderlist').stop().hide()}
   )
});";

$document = JFactory::getDocument();
$document->addScriptDeclaration($js);
//var_dump($this->category);
?>

<?php
/* Show child categories */
if ( VmConfig::get('showCategory',1) and empty($this->keyword)) :
   if (!empty($this->category->haschildren)) :
      // Category and Columns Counter
      $iCol = 1;
      $iCategory = 1;
      // Calculating Categories Per Row
      $categories_per_row = VmConfig::get ( 'categories_per_row', 3 );
      $category_cellwidth = ' width'.floor ( 100 / $categories_per_row );
      $BrowseTotalProducts = count($this->products[0]);
      // Separator
      $verticalseparator = " vertical-separator";
   ?>
   <div class="category-view">
      <?php // Start the Output
      if(!empty($this->category->children)) :
         foreach ( $this->category->children as $category ) : ?>
            <?php if ($iCol == 1 && $iCategory > $categories_per_row) : ?>
            <div class="horizontal-separator"></div>
            <?php endif; ?>
            
            <?php if ($iCol == 1) : ?>
            <div class="row">
            <?php endif; ?>
            
            <?php
               // Show the vertical seperator
               if ($iCategory == $categories_per_row or $iCategory % $categories_per_row == 0) {
                  $show_vertical_separator = ' ';
               } else {
                  $show_vertical_separator = $verticalseparator;
               }
      
               // Category Link
               $caturl = JRoute::_ ( 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id );
      
                  // Show Category ?>
                  <div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
                     <div class="spacer">
                        <a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>"><?php echo $category->images[0]->displayMediaThumb("",false); ?></a>
                        
                        <h2 class="catSub"> <a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>"> <?php echo $category->category_name ?> </a> </h2>
                        
                        <a href="<?php echo $caturl; ?>" class="category-overlay"><span><span><?php echo JText::_('TPL_GK_LANG_VM_VIEW'); ?></span></span></a>
                     </div><!-- .spacer -->
                  </div><!-- .category -->
                  <?php
               $iCategory ++;
      
            // Do we need to close the current row now?
            if ($iCol == $categories_per_row) : ?>
               <div class="clear"></div>
            </div><!-- .row -->
            <?php
               $iCol = 1;
            else :
               $iCol ++;
            endif;
         endforeach;
      endif;
      // Do we need a final closing row tag?
      if ($iCol != 1) : ?>
         <div class="clear"></div>
      </div><!-- .row -->
      <?php endif; ?>
   </div><!-- .category-view -->
<?php
   endif;
endif;
?>

<div class="browse-view">
<?php
   // Show child categories
   if (!empty($this->products)) {
      //revert of the fallback in the view.html.php, will be removed vm3.2
      if($this->fallback){
         $p = $this->products;
         $this->products = array();
         $this->products[0] = $p;
         vmdebug('Refallback');
      }

      $BrowseTotalProducts = count($this->products[0]); ?>
         
      <?php if (!empty($this->keyword)) : ?>
      <h1><?php echo $this->keyword; ?></h1>
      <?php endif; ?>
      
      <?php // Category and Columns Counter
         $iBrowseCol = 1;
         $iBrowseProduct = 1;
         
         // Calculating Products Per Row
         $BrowseProducts_per_row = $this->perRow;
         $Browsecellwidth = ' width'.floor ( 100 / $BrowseProducts_per_row );
         
         // Separator
         $verticalseparator = " vertical-separator";
      ?>
   
      <?php if(!empty($this->category->category_name)) : ?>
      <h1><?php echo $this->category->category_name; ?></h1>
      <?php endif; ?>
      
      <?php if (empty($this->keyword) && !empty($this->category) && !empty($this->category->category_description)) : ?>
      <p class="category_description">
         <?php echo $this->category->category_description; ?>
      </p>
      <?php endif; ?>
      
      <form action="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=category&limitstart=0&virtuemart_category_id=' . $this->category->virtuemart_category_id, FALSE); ?>" method="get">
            <?php if (!empty($this->products)) : ?>
            <div class="orderby-displaynumber"><?php echo $this->orderByList['orderby']; ?>
                  <div class="display-number"><?php echo $this->vmPagination->getResultsCounter();?> <?php echo $this->vmPagination->getLimitBox ($this->category->limit_list_step); ?></div>
                  
            </div>
            <?php endif ?>
      </form>
      <?php // Start the Output
      foreach ( $this->products as $product ) :
         // Show the horizontal seperator
         if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) : ?>
         <div class="horizontal-separator"></div>
         <?php endif;
   
         // this is an indicator wether a row needs to be opened or not
         if ($iBrowseCol == 1) : ?>
         <div class="row">
         <?php endif;
   
            // Show the vertical seperator
            if ($iBrowseProduct == $BrowseProducts_per_row or $iBrowseProduct % $BrowseProducts_per_row == 0) {
               $show_vertical_separator = ' ';
            } else {
               $show_vertical_separator = $verticalseparator;
            }
            // Show Products ?>
            <div class="product floatleft<?php echo $Browsecellwidth . $show_vertical_separator ?>">
               <div class="spacer">
                  <div>
                     <a title="<?php echo $product->product_name ?>" href="<?php echo $product->link; ?>">
                        <?php
                           echo $product->images[0]->displayMediaThumb('class="browseProductImage"', false);
                        ?>
                      </a>
                  </div>
                  
                  <div>
                     <h3 class="catProductTitle"><?php echo JHTML::link($product->link, $product->product_name); ?></h3>
                     
                     <div class="catProductPrice" id="productPrice<?php echo $product->virtuemart_product_id ?>">
                        <?php
                        if ($this->show_prices == '1') :
                           if ($product->prices['salesPrice']<=0 and VmConfig::get ('askprice', 1) and  !$product->images[0]->file_is_downloadable) :
                              echo JText::_ ('COM_VIRTUEMART_PRODUCT_ASKPRICE');
                           endif;
                           echo $this->currency->createPriceDiv('salesPrice', '', $product->prices);
                           echo $this->currency->createPriceDiv('taxAmount','TPL_GK_LANG_VM_INC_TAX', $product->prices);
                        endif; ?>
                     </div>
                     
                     <?php if ( VmConfig::get ('display_stock', 1)) : ?>
                     <div class="stockLavel"> <span class="vmicon vm2-<?php echo $product->stock->stock_level ?>" title="<?php echo $product->stock->stock_tip ?>"></span> <span class="stock-level"><?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP') ?></span> </div>
                     <?php endif; ?>
                  </div>
                  
                  <a href="<?php echo $product->link; ?>" class="product-overlay"><span><span><?php echo JText::_('TPL_GK_LANG_VM_VIEW'); ?></span></span></a>
               </div><!-- .spacer -->
            </div><!-- .product -->
         <?php
      
         // Do we need to close the current row now?
         if ($iBrowseCol == $BrowseProducts_per_row || (isset($BrowseTotalProducts) && $iBrowseProduct == $BrowseTotalProducts)) : ?>
            </div><!-- .row -->
            <?php
            $iBrowseCol = 1;
         else :
            $iBrowseCol++;
         endif;
      
         $iBrowseProduct++;
      endforeach;
      // Do we need a final closing row tag?
      if ($iBrowseCol != 1) : ?>
         <div class="clear"></div>
      </div><!-- .row -->
      <?php endif; ?>
   
      <?php if($this->vmPagination->getPagesLinks() != '') : ?>
      <div class="pagination">
         <?php echo str_replace('</ul>', '<li class="counter">'.$this->vmPagination->getPagesCounter().'</li></ul>', $this->vmPagination->getPagesLinks()); ?>
      </div><!-- .pagination -->
      <?php endif; ?>
   <?php
   elseif (!empty($this->keyword)) :
      echo JText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : (' . $this->keyword . ')' : '');
   endif;
   ?>
</div><!-- .browse-view -->

Thanks in advance
User avatar
Senior Boarder

GK User
Thu Dec 22, 2016 12:42 pm
In your case, you need to revert all changes and then re apply them step by step, checking each change before proceeding to the next step. As you are using a different template than me, you need to figure it out where the changes should be made.
User avatar
Expert Boarder

teitbite
Sat Dec 31, 2016 9:26 am
Hi

@razor7 is right. It's hard to tell from just looking at that. @mittelcom please send me an access to Your ftp and please do not forget about url to the page where I'll be bale to see this error.
User avatar
Moderator

GK User
Wed Jan 04, 2017 12:05 pm
Teitbite, I've sent you a private message with access info, did you receive it?
User avatar
Senior Boarder

teitbite
Mon Jan 09, 2017 10:26 am
Hi

@mittelcom, Yes I got it and fixed it by changing one more line additionally to the original solution presented in this thread. Line:

Code: Select all
    <?php // Start the Output
    foreach ( $this->products as $product ) :


I've changed to:

Code: Select all
    <?php // Start the Output
    foreach ( $this->products[0] as $product ) :
User avatar
Moderator

GK User
Thu May 11, 2017 2:37 pm
Hello, I get the same problem. Fatal error: Call to a member function displayMediaThumb() on null in /home/vamradby/public_html/templates/gk_storefront/html/com_virtuemart/category/default.php on line 189. My site https://vamrad.by/. I use PHP 5.6. VirtueMart 3.2.1 Joomla 3.7.0 GK Storefront 3.22
User avatar
Fresh Boarder

teitbite
Sun May 14, 2017 1:48 pm
Hi

Please send me an access to joomla panel to my mail [email protected] so I'll check.
User avatar
Moderator

GK User
Tue May 16, 2017 1:09 am
Are there novelties? I also have the same problem

thank you
User avatar
Fresh Boarder

GK User
Tue May 16, 2017 6:16 pm
imbro wrote:Are there novelties? I also have the same problem

thank you



The problem is on the product default page , If renamed, so disable it works well
But you can not see it with the virtuemart default page,It's ugly
User avatar
Fresh Boarder

GK User
Tue May 16, 2017 11:46 pm
Hi, I have a similar problem after updating VirtueMart from 3.0.x to 3.2.2. On some product detail pages (and this is strange, because it's not all products), for example this one:
http://metaaccion.com/tienda-virtual-me ... etail.html
I get this error:
"0
Call to a member function displayMediaThumb() on null
It appears the page you were looking for doesn't exist. Sorry about that."
You can see the product photo, description, price and all other information, except that the menu bar and company logo are missing, and the previous error message appears at the very bottom of the page.

My website has
Joomla 3.6.5, php 7.0, VirtueMart 3.2.2, and StoreBox template
What I have already done is:
Download the newest StoreBox template files and uploaded them to my website
Disabled gk_storebox/html/com_virtuemart/productdetails/default.php

With gk_storebox/html/com_virtuemart/productdetails/default.php disabled, I don't get the error I mentioned above, but as you can see, the word "zoom" appears right below the photo and the effect of the product overlay has disappeared. How can I fix this, so I get the nice effect of the "zoom" circle going up and down the product photo on hover?
User avatar
Fresh Boarder

teitbite
Thu May 18, 2017 7:49 pm
Hi

I got no news since I've never got an access to ftp and joomla panel of the site where this problem can be seen. Please one of You send it to me so I'll be able to check the problem. [email protected]
User avatar
Moderator

teitbite
Wed May 24, 2017 8:45 am
Hi

Thank You for the access @amruffatti. I've renamed the file to default.php and shown it to programmers. Please keep it like that till they fix it. Will present solution here for rest interested as soon as they will reply.
User avatar
Moderator

GK User
Wed May 24, 2017 2:44 pm
Hi
A client of mine has the same problem on product details (Joomla! 3.7.2 VM 3.2.2 template Storefront)!
I hope a new version will come soon.
Robert
User avatar
Fresh Boarder

teitbite
Thu May 25, 2017 4:44 pm
Hi

Programmers are in the middle of updating VM, but it may take couple of days. Please wait with VM update or rename html/com_virteumart/productdetails/default.php file so a default VM file will be used.
User avatar
Moderator

GK User
Fri Jun 02, 2017 2:02 pm
Hi,
No news for Storefront template?
Thanks,
Robert
User avatar
Fresh Boarder

teitbite
Mon Jun 05, 2017 11:35 am
Hi

Not yet. Please observer update page to be notified when it will be relaesed https://www.gavick.com/updates
User avatar
Moderator

GK User
Tue Jun 13, 2017 4:51 pm
Hi, I don't see an update yet on the link you provided. How much longer do you think it'll take?
User avatar
Fresh Boarder

GK User
Tue Jun 13, 2017 7:18 pm
I think I may have fixed it. Virtuemart 3.2.2 and StoreBox are now working correctly. All products display with the complete template, and the product variants show the correct price for each variant. The problem was not only in /productdetails/default.php, but also in /category/default.php. I disabled /productdetails/default.php and made changes to /category/default.php. I would still like to eliminate the word "zoom" from the product details pages, so I'll do that in a little while. Look into my server, pull out the files you need, and test them. I did make some changes to sublayouts/price.php that you may not need.

Now all you have to do is buy me ice cream, or extend my Gavick membership or something.
User avatar
Fresh Boarder

teitbite
Sat Jun 17, 2017 2:37 pm
Hi

That's great, but from what I know programmers are working from scratch using the newest files of VM to be integrated with templates. So that's why it's taking that long, plus it has to be added to 8 templates at once. Soon it will be released, but I cannot tell You the exact time, since I'm not working with them on this changes.
User avatar
Moderator

teitbite
Wed Jul 19, 2017 10:12 am
Hi

Got an information that most fragile issues has been covered and it's safe to update, but I had no chance to test it yet, so making a backup before is highly recommended.
User avatar
Moderator


cron
Remember me
Register New Account
If you are old Gavick user, click HERE for steps to retrieve your account.