News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Error "Call to a member function displayMediaThumb() on null" - VM 3.2.2

Started by valekichia, May 16, 2017, 18:13:28 PM

Previous topic - Next topic

valekichia

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

jenkinhill

Using a commercial template?  Test with Protostar to check if a template issue.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

valekichia

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

Typhoon365

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.

valekichia

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?

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

valekichia

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...


jenkinhill

I thought full_catname_tree affected BE & FE - but I have not needed to use it.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

valekichia

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?)

Geppux

Same happens to me, and clicking on  "Display Subcategories in product details" the error goes away...
I'll contact also the template company...

spiri

Ticking "Enable legacy layouts" in the same config page worked for me //still testing 

samuelmf

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
Joomla 1.5.20 / VirtueMart 1.1.5

oneyozfest182

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.