Hi Jerome, thanks for the fast reply.
I think that I need to clarify the difference between the front-end and-back end in the context of what I am trying to do.
Some more information...
I am writing a plugin that has no front end GUI. All methods are within the plugins main class. The plugin is of type group="hikashop" and the main class extends the JPlugin class. There is no part of the plugin visible or accessible from the 'front-end'.I assume that my plugins scope is therefore entirely within the 'back-end'.
The user that I am testing with has normal vendor permissions and is not a superuser or admin.
I still cannot see product_vendor_id when creating a new product within the onBeforeProductcreate method. Additionally if I perform a var_dump($product) within onBeforeProductcreate product_vendor_id is not present in the output.
I have partially solved this problem by fetching product_vendor_id from the #__hikashop_product table in the database, but this is only works for the onBeforeProdictUpdate method as the product record already exists. This solution does not work for the onBeforeProductcreate method as there is no actual database record at this time.
If it is not possible to access product_vendor_id I will have to use the user_id to look up the product_vendor_id from the #_hikamarket_vendor table. I should be able get this from $user =& JFactory::getUser(); However it seems strange that I cannot access product_vendor_id when it seems likely that I should be able to.
If you are sure that product_vendor_id should be accessible (as I have assumed) then there is perhaps some problem with what I am doing or maybe with hikashop?
Here is the code I am using.
function onBeforeProductcreate(&$product, &$do) {
//add todays date
$dt = new DateTime();
$product->date_added = $dt->format('d-m-Y');
$file_id = $product->files[0];
// Get filepath data from database.
$db = JFactory::getDbo();
$query = "SELECT `file_path` FROM `#__hikashop_file` WHERE `file_id` = '$file_id' AND `file_type` = 'file' ORDER BY `file_id` DESC LIMIT 1";
$db->setQuery($query);
$file_path = $this->dl_path . $db->loadResult();
$file_name = substr($file_path, strrpos($str, '/') + 1);
$file_ext = substr($file_path, strrpos($file_path, '.') + 1);
if ($file_ext == 'ext') {
$product_vendor_id = $product->product_vendor_id;
$this->preLoader($file_path);
$product->word_count = $this->getWords() . ' words';
$product->page_count = $this->getPages() . ' grams';
$product->preview_url = '<a class="modal hikashop_cart_button" rel="{handler:\'iframe\',size:{x:800,y:560}}" href="http://mysite.com/files/' . $product_vendor_id . '/' . test.php?file=' . $file_name .'" onclick="SqueezeBox.fromElement(this,{parse: \'rel\'});return false;" > File Viewer</a>';
}
}
Any thoughts?
Regards
/DM
PS. Your preview pane is sometimes not working for me - (Mac OSX + Firefox)