Author Topic: Custom attributes of Manufacturers & how to access them via DOM in Details Page  (Read 283 times)

dartagnon

  • Beginner
  • *
  • Posts: 9
  • A beginner
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
  • public_html/templates/<template_name>/html/com_virtuemart/manufacturer/details.php
I see code like below that doesn't show the logo, nor the custom data in mf_lang column of the manufacturer table;

Code: [Select]
$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
  • Recognise the additional columns in the manufacturer table?
  • Access the additional attributes via document object model?

I'm fairly new to Joomla/PHP/VirtueMart to make things worse... so please let me know if I left out any important information.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3955
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
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.

dartagnon

  • Beginner
  • *
  • Posts: 9
  • A beginner
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.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8948
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
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
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

dartagnon

  • Beginner
  • *
  • Posts: 9
  • A beginner
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.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8948
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
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
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

dartagnon

  • Beginner
  • *
  • Posts: 9
  • A beginner
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.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3955
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
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.

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+
why not keep the data in a separate table? with manufacture ID matching?
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)