Hi,
Yes. To add that code to the product edit form from a plugin, you want to implement the event onProductFormDisplay(&$product, &$html) and you can add your HTML as a new entry in $html.
Note however that in that case, you can't choose the location of your HTML. It will be in the "Fields" section, after the custom product fields. That's why I was recommending a view override sine you wanted to place it elsewhere in the interface.
To load the search field dynamically, like we have in some places, it's possible, but much more complex.
First, you need to implement the event onNameboxTypesLoad(&$loaded_types) to add your own type of search field. That way, instead of "rawlist" you can use that type.
Here is an example I made for a custom development to get a search field to select users:
function onNameboxTypesLoad(&$loaded_types)
{
$loaded_types['client_selector'] = array(
'class' => 'class.user',
'name' => 'user_id',
'mode' => 'list',
'displayFormat' => '{user_id} - {name}',
'url' => 'xxx&task=getValues',
'options' => array(
'olist' => array(
'table' => array('user_id' => 'ID', 'name' => 'HIKA_NAME', 'user_email' => 'HIKA_EMAIL'),
'displayFormat' => '{user_id} - {name}',
)
)
);
}
where xxx is the folder name of the plugin.
Then, you also need to implement the event onHikashopPluginController($ctrl) in order to add your own controller to HikaShop, like so:
public function onHikashopPluginController($ctrl)
{
if (!in_array($ctrl, array('xxx')))
return;
$prefix = 'ctrl';
if (!hikashop_isClient('administrator'))
return;
// register the controller for the client selector
return array(
'type' => 'hikashop',
'name' => 'xxx',
'prefix' => $prefix,
);
}
And then you need a file xxx_ctrl.php in your plugin. In that file, you need code like this to define the controller and the task getValues:
<?php
/**
*
*/
class xxxController extends hikashopController {
public $display = array('getValues');
public $modify_views = array();
public $add = array();
public $modify = array();
public $delete = array();
public $pluginCtrl = array('hikashop', 'xxx');
public $type = 'plg_xxx';
/**
*
* @param array $config
* @param boolean $skip
*/
public function __construct($config = array(), $skip = false) {
parent::__construct($config, $skip);
if(!$skip)
$this->registerDefaultTask('listing');
}
/**
*
*/
protected function getACLName($task) {
return '';
}
/**
* user data feeder for the client selector
*/
public function getValues() {
$displayFormat = hikaInput::get()->getVar('displayFormat', '');
$search = hikaInput::get()->getVar('search', null);
$start = hikaInput::get()->getInt('start', 0);
$nameboxType = hikashop_get('type.namebox');
$options = array(
'start' => $start,
'displayFormat' => $displayFormat
);
$ret = $nameboxType->getValues($search, 'user', $options);
if(!empty($ret)) {
echo json_encode($ret);
exit;
}
echo '[]';
exit;
}
}
The line:
$ret = $nameboxType->getValues($search, 'user', $options);
will return the data of the users necessary from the getValues function of administrator/components/com_hikashop/types/namebox.php
This function actually uses the getNameboxData function of administrator/components/com_hikashop/classes/user.php
So you'll have to adapt all this to your needs. You're in for at least several hours of work.
I think it's quite complex for a marginal gain. I would recommend you to stick with the code I gave in my previous message. Loading a few thousand elements in a Javascript array is not a problem.