VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: valekichia on May 16, 2017, 18:13:28 PM

Title: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: valekichia on May 16, 2017, 18:13:28 PM
Hello everybody.

I'm experiencing some issues after updating VM to version 3.2.2 (J version 3.7.0).

My VM category tree looks like this:

[root]
- main category 1
-- sub category 1
-- sub category 2
-- sub category 3
--- sub sub category 3a
--- sub sub category 3b
--- sub sub category 3c
- main category 2 ...
- main category 3 ...

I get error "Call to a member function displayMediaThumb() on null" on some product details pages and the layout gets broken.

It happens on products which are assigned to sub sub categories, when accessing the product details page from a category which isn't the deepest one.

For example, if I have a product in sub sub category 3a (also assigned to sub category 3 and main category 1), the product details page will be ok only accessing it through sub sub category 3a category view. Otherwise I get the error, that is from other categories or from VM homepage.

It that can be of any help, I set "Show products of subcategories" on yes in VM config.

I assign some products to all the levels of the nested categories because, despite this configuration, they won't be displayed in each category level.

If I assign the products only to the deepest subcategory the error won't show, but I loose the feature above...

Any ideas? ...may be I'm missing something... Can anybody help?

Thank you
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: jenkinhill on May 16, 2017, 23:03:15 PM
Using a commercial template?  Test with Protostar to check if a template issue.
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: valekichia on May 17, 2017, 11:41:55 AM
Hi jenkinhill, thank you for your reply!

I'm using a custom template, based on Helix framework (I don't know if I can mention it here, if not sorry, delete the info).

I tried Protostar and no problems occurred.

So now I know is a template issue.

I know that this makes it harder (if not impossible) for you to tell where the problem comes from, but may be I'm lucky and you can at least point me in the right direction and tell me where to "look" to solve it...

Thank you again
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: Typhoon365 on May 17, 2017, 17:37:31 PM
We are also experiencing the same issue after updating to VM 3.2.2.

As a temporary work-around, we found if we tick the "Display Subcategories in product detail" in Virtuemart Configuration->Templates the error would go away and the product details would display properly. 

The side symptom of this workaround, is it will display any child categories at the bottom on the product page (ie. child categories of the category the product belongs to). 

We are also using a custom template and a few overrides. We found this config change worked for us for now until we can look at it further.
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: valekichia on May 17, 2017, 22:36:57 PM
Hello Typhoon365!

I tried your suggestion and I confirm that with the tick in "Display Subcategories in product details" the error goes away, with the downside that you noticed.

Since I'm also using some overrides, your suggestion let me think that maybe the issue was in the productdetails page override (ie. mytemplate/html/com_virtuemart/productdetails/default.php).

So I checked the pre-update and the after-update file components/com_virtuemart/views/productdetails/tmpl/default.php to check if there were any differences between the two (aside from my overrides, of course).

I discovered that line 253 has changed!

Before:
if (VmConfig::get('showCategory', 1)) {

After:
if ($this->cat_productdetails)  {

Honestly I'm not so skilled to tell if everything arises from this...

But in the end I copied my overrides on the new default.php file and uploaded it again as an override, then unchecked the "Display Subcategories in product detail" option and everything works fine (or at least seems to, I'm testing) without having the child categories displayed at the bottom of the product page.

I hope this can be of any help for you too...

However, one thing I still don't understand is why the "Show products of subcategories" option only works for 1 level of depth. That is the products belonging only to a sub sub category are not displayed on main category page.
Any ideas anybody?
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: jenkinhill on May 17, 2017, 23:33:59 PM
Maybe http://forum.virtuemart.net/index.php?topic=137491.msg481455#msg481455
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: valekichia on May 18, 2017, 10:41:05 AM
Hi jenkinhill!

I read the post at your link but I think it was about backend, am I right?

I'm speaking about frontend display instead...

Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: jenkinhill on May 18, 2017, 11:50:12 AM
I thought full_catname_tree affected BE & FE - but I have not needed to use it.
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: valekichia on May 18, 2017, 15:45:59 PM
Hi jenkinhill,

I tried the hidden configuration but I confirm it only affects BE!

Nothing changed in FE.

Do you have any ideas to achieve what I need? (products from 2nd level subcategores to be displayed in each level of the category tree?)
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: Geppux on May 26, 2017, 16:31:46 PM
Same happens to me, and clicking on  "Display Subcategories in product details" the error goes away...
I'll contact also the template company...
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: spiri on June 07, 2017, 10:16:24 AM
Ticking "Enable legacy layouts" in the same config page worked for me //still testing 
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: samuelmf on August 22, 2017, 19:31:22 PM
For me, ticking the "Display Subcategories in product details" woked but, there is no way to hide the subcategories without lose the layout?

On my case i use helix 3
Title: Re: Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2
Post by: oneyozfest182 on January 09, 2018, 15:41:14 PM
Quote from: valekichia on May 17, 2017, 22:36:57 PM
Hello Typhoon365!

I tried your suggestion and I confirm that with the tick in "Display Subcategories in product details" the error goes away, with the downside that you noticed.

Since I'm also using some overrides, your suggestion let me think that maybe the issue was in the productdetails page override (ie. mytemplate/html/com_virtuemart/productdetails/default.php).

So I checked the pre-update and the after-update file components/com_virtuemart/views/productdetails/tmpl/default.php to check if there were any differences between the two (aside from my overrides, of course).

I discovered that line 253 has changed!

Before:
if (VmConfig::get('showCategory', 1)) {

After:
if ($this->cat_productdetails)  {

Honestly I'm not so skilled to tell if everything arises from this...

But in the end I copied my overrides on the new default.php file and uploaded it again as an override, then unchecked the "Display Subcategories in product detail" option and everything works fine (or at least seems to, I'm testing) without having the child categories displayed at the bottom of the product page.

I hope this can be of any help for you too...

Sorry to revive an old topic, but I just wanted to let anyone else know that may be experiencing this, (as it just started happening to me), I'm using the protostar template and still got plagued with this, but replacing just if (VmConfig::get('showCategory', 1)) { with if ($this->cat_productdetails)  { in my override file completely solved this, so that line of code was 100% the issue causing the problem.