VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: dartagnon on August 05, 2019, 08:38:38 AM

Title: Custom attributes of Manufacturers & how to access them via DOM in Details Page
Post by: dartagnon on August 05, 2019, 08:38:38 AM
Hello Virtuemart experts,

I have inherited a custom, outdated and broken Virtuemart site, whose software level was very old (PHP 5.x, VirtueMart 3.0.x, Joomla ... cannot remember what it was before).
Since taking it over, I've updated PHP to 7.2, VirtueMart to 3.4.5 & Joomla to 3.9.x, only to realise some of the plugins & custom templates are not working any more.

One of them is the existing site has additional columns for Manufacturers (renamed to 'Artists') in MySQL table - eg. Nationality, Language, etc.

The table still contains data after the upgrade as far as I can tell, but the existing code cannot access them through the PHP/Joomla object model any more.

I can see in the custom template in
I see code like below that doesn't show the logo, nor the custom data in mf_lang column of the manufacturer table;

$document = JFactory::getDocument();
...
<p> <?php $this->manufacturerImage ?> </p>

<?php if(!empty($this->manufacturer->mf_lang)) : ?>
<span class="lbl">Language : <?php echo $this->manufacturer->mf_lang?></span>


Data from default VirtueMart fields does show up it seems.

So... how to I make the code to

I'm fairly new to Joomla/PHP/VirtueMart to make things worse... so please let me know if I left out any important information.
Title: Re: Custom attributes of Manufacturers & how to access them via DOM in Details Page
Post by: Studio 42 on August 05, 2019, 13:12:05 PM
To view the object try
var_dump($this->manufacturer);

But i think that the Virtuemart core files was hacked, it's why you dont get all informations after update.
If you have a backup, try to extract and compare the old and new files.
Title: Re: Custom attributes of Manufacturers & how to access them via DOM in Details Page
Post by: dartagnon on August 06, 2019, 03:18:48 AM
Hi Studio 42,
Thanks for the reply. I'll see what gets printed from the object using your code.

If Virtuemart core files were hacked - is there a way to just reinstall them? Would have thought the 'update' should overwrite the core files?
As for the backup... there are some old backups but there would be a big difference since so many outdated plugins along with Joomla got updated in one go (Should have done slowly one by one... but I didn't know any better!)
I would appreciate some pointers as to which files are likely driving the manufacturer functions.

Thanks again.
Title: Re: Custom attributes of Manufacturers & how to access them via DOM in Details Page
Post by: GJC Web Design on August 06, 2019, 16:42:04 PM
the VM system is quite straight forward .. 

the $manufacturer is constructed in the administrator/components/com_virtuemart/models/manufacturer.php

normally the object is created by the getTable() function which calls administrator/components/com_virtuemart/tables/manufacturers.php

If u don't mind core hacks you can add the extra fields there
Title: Re: Custom attributes of Manufacturers & how to access them via DOM in Details Page
Post by: dartagnon on August 07, 2019, 13:48:33 PM
Thank you GJC Web Design! that was it!!!

I've updated those two files to include the extra columns, and the information stored in the DB are now showing up on the page via the manufacturer model.
Could I trouble you for a couple more pointers related to this issue?

1. Is there a way to persist this change, independent of Joomla / VirtueMart updates? OR should I simply make backup of those two files, and make sure they are copied back each time?

2. I'm guessing that the former design would have had some customisation done to the VirtueMart manufacturer profile page to enter those extra data into the table.
Could you point me to where the manufacturer profile page is in VirtueMart, so that I can add these fields onto the VirtueMart Manufacturer admin page?

Appreciate your help.
Title: Re: Custom attributes of Manufacturers & how to access them via DOM in Details Page
Post by: GJC Web Design on August 07, 2019, 14:42:52 PM
1. it is complex ..  you need to over ride the function or make a system plugin to add this data.. simplest is to just remake the hack each time

2. if these are extra fields with inputs then they would be added @
\administrator\components\com_virtuemart\views\manufacturer\tmpl\edit_description.php

you can over ride this in the conventional manner to the Isis template

if the fields are already added to the tables/manu then they should save
Title: Re: Custom attributes of Manufacturers & how to access them via DOM in Details Page
Post by: dartagnon on August 08, 2019, 01:14:19 AM
Thank you GJC Web Design,
I've added the fields and the data shows up in the fields correctly.
Thanks to your pointers I am able to get my head around the VirtueMart codes a bit better.

I'll heed the warning and make a backup directory to store all customised php pages to re-deploy after VM upgrades in the future.
Title: Re: Custom attributes of Manufacturers & how to access them via DOM in Details Page
Post by: Studio 42 on August 08, 2019, 12:26:44 PM
Always do a template override when it's possible(or in some case a plugin). You can do many thinks without hacking the core files.
Title: Re: Custom attributes of Manufacturers & how to access them via DOM in Details Page
Post by: PRO on August 08, 2019, 16:53:32 PM
why not keep the data in a separate table? with manufacture ID matching?