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

trying to add custom field in admin: stopped on getTable method

Started by sshake, September 17, 2013, 09:14:48 AM

Previous topic - Next topic

sshake

Good morning everyone,
I am trying to add a custom field in the admin panel -> product add/edit tab.
The new field is a select similar to manufacturer dropdown select and it gets populated from tables i previously inserted in the database.

Now, in order to get things working I am modifying the product model  following the same logic applied to the manufacturers.


I am stucked on the getTable method which is often used in the product model as well in others models.
If I well understood it is a general method of the Joomla system defined in:
libraries/joomla/application/component/model.php in which you can see:
public function getTable($name = '', $prefix = 'Table', $options = array())
{

if (empty($name))
{
$name = $this->getName();
}

if ($table = $this->_createTable($name, $prefix, $options))
{
return $table;
}

JError::raiseError(0, JText::sprintf('JLIB_APPLICATION_ERROR_TABLE_NAME_NOT_SUPPORTED', $name));

return null;
}


but it seems I'm wrong because if I comment everything inside the product admin panel also works.


So my question is: where is the getTable method (which is called in virtuemart models) DEFINED?

Many thanks!

Maxim Pishnyak

Why you can't use custom fields for your goal? What is your goal?
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

sshake

Hi there,
Yes of course, I know i can use custom attributes but a custom field in the edit/add tab save a lot of time when you have to insert hundreds of product per day.

Moreover, if you have your custom select with values stored in db you can avoids errors which could be in the entry of custom attributes.

Moreover, a custom attribute is an "isolated" value; on the other hand a value (like manufacturer) that you choose from an additional table you create (example: the selling point) can be related to a whole structure of data (example: size of the shop, location/locations, etc) that you can retrieve.

So is there any good man willing to explain how the getTable method works.

Many thanks
Fabio.

Maxim Pishnyak

Quote from: sshake on September 17, 2013, 11:05:47 AM
Hi there,
Yes of course, I know i can use custom attributes but a custom field in the edit/add tab save a lot of time when you have to insert hundreds of product per day.
CSVI Improved.

http://translate.google.com.ua/translate?hl=ru&sl=auto&tl=en&u=http%3A%2F%2Fjoomlaforum.ru%2Findex.php%2Ftopic%2C230522&sandbox=1
I'm a good man now.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

sshake

Hi Maxim,
Many thanks for your quick answers.
Let's put it simple in the product model we have this notation:

line: 988
$mfTable = $this->getTable ('manufacturers');

this getTable methods repeated hundreds of times in product model as well as inother models.

Can someone tell me where it is defined?

As told before it seems to be a Joomla method defined in  :libraries/joomla/application/component/model.php

but as I told if you comment all the content inside the getTable function everything works fine.

Many thanks. Fabio.