0

first of all, sorry for my english, but I'll try to explain myself best I can.

My question is little tricky, because I made some important changes in the core code of VirtueMart. For some reasons, I added an attribute to the Custom Fields, like Price, called Availability.

enter image description here TIP: The admin site is in Spanish. Disponibilidad = Availability

So, now, when I try to change any value of any created Custom Field, I can't save it. I mean, I can change the value, but when I apply them, It doesn't be saved.

The only field that I can change, is the field I created, the Availability (ironically).

So, my principal question is, how does VirtueMart to pick up the data from the table and sends them to the database?

I work with

  • Joomla v.2.5.11
  • VirtueMart 2

Thanks

Arnau Lacambra
  • 130
  • 1
  • 7
  • 1
    When you say *Availability*, I assume you mean whether it's *in stock* or not. Isn't there a field for this in VirtueMart already? – Lodder Jan 16 '14 at 19:19
  • As lodder already said there is one field available in VM2.x names Availability then why you want to create custom fields? – Jobin Jan 17 '14 at 02:44
  • Is true, exists a type of custom field, which can work with Availability attribute, but for the work done inside the website before I start working on it, and the customer's requirements, this was (I thought) the best way to work it. – Arnau Lacambra Jan 17 '14 at 14:31

1 Answers1

2

The workflow is like follows,

When you save the products details on the backend , It calls a function store() on the product.php model. under administrator/components/com_virtuemart/models/. Inside this function an area like follows.

if(!class_exists('VirtueMartModelCustom')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'custom.php');

            VirtueMartModelCustom::saveModelCustomfields('product',$data,$product_data->virtuemart_product_id);

It loading the custom model file from the same path and do the task inside saveModelCustomfields()

Hope it helps..

Jobin
  • 8,238
  • 1
  • 33
  • 52
  • Thanks for the answer, I've finally figured out how it works! Just to point out, the function in the custom model file (customfields.php) isn't called saveModelCustomFields(). The actual name is storeProductCustomfields(). Now I know what is happening. The var which contains all the data ($datas), should contain also an attribute called 'plugin_param', but it doesn't, so the function who supposed saves the data, it's never triggered. Any idea? – Arnau Lacambra Jan 17 '14 at 15:44
  • Here the code `if (isset($datas['plugin_param']) and is_array($datas['plugin_param'])) { foreach ($datas['plugin_param'] as $key => $plugin_param) { $dispatcher->trigger('plgVmOnStoreProduct', array($datas, $plugin_param)); } }` – Arnau Lacambra Jan 17 '14 at 15:45
  • I solved it. The problem was with other part that I changed too. Thanks for the answers. – Arnau Lacambra Jan 23 '14 at 14:55