onBeforeProductListingLoad() Enhancement

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
12 years 9 months ago #20479

Would it be possible to extend the call to this trigger to something like:

$dispatcher->trigger( 'onBeforeProductListingLoad', array( & $filters, & $order, & $this) );
Similarly for the onBeforeCategoryListingLoad trigger.

I am implementing a search facility which lists the products using the product list views, not 100% certain I would need to use this information at the moment, but providing it would give direct access to all the information related to the request.

*** After a bit more investigation passing $this into the plug-in would be very useful. Can modify the view template for the Display / Content Menu form (e.g. add a searchable parameter to it) which can then be checked for in the plug-in.

Last edit: 12 years 9 months ago by brainforge. Reason: Added note about Content Menu form

Please Log in or Create an account to join the conversation.

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
12 years 9 months ago #20511

There are some problems with that:
1. The $this of the category trigger and of the product trigger are not the same. So it's not consistent.
2. The existing plugins which already implement these triggers will crash if called with these additional parameters if the persons developing them don't modify their code. So doing that would hinder backward compatibility.
But I see the possible applications of adding such parameters in the trigger and that indeed sound interesting.

Do you have any suggestions regarding these points ?

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
12 years 9 months ago #20514

1. The 2 triggers are different, so would not be an issue.
In the plugin the functions could be defined as:

function onBeforeProductListingLoad(&$filters, &$order, &$productView){...}
function onBeforeProductListingLoad(&$filters, &$order, &$categoryView){...}

2. In my installations (currently 5.3) PHP handles variable parameters lists with additional parameters being ignored by the interpreter. Only if one where to be removed would there be a problem.

I have tested this with the following code and it worked fine:
...
$dispatcher->trigger( 'onBeforeProductListingLoad', array( & $filters, & $order, & $this) );
...
class plgHikashopBf_Search extends JPlugin{
//  function onBeforeProductListingLoad(&$filters, &$order, &$view) {
//    $searchable = trim($view->params->get('searchable'));
//    if (empty($searchable)) return;
  function onBeforeProductListingLoad(&$filters) {
    $searchable = 'product_name,product_description';
...
  }
}
The searchable parameter is an additional field I put into my template view override for the menu form.php file.

Please Log in or Create an account to join the conversation.

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
12 years 9 months ago #20542

Great then. We'll do that.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
12 years 9 months ago #20555

Thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
12 years 9 months ago #20629

Just realised that the 'onBeforeProductListingLoad' trigger is called from the administration screens as well as the site screens.

The change:

$dispatcher->trigger( 'onBeforeProductListingLoad', array( & $filters, & $order, & $this) );
needs to be made to views/product/view.html.php in both places please.

Also, although I am not using it, I looked for the call to 'onBeforeCategoryListingLoad' and found it in classes/category.php rather than views/category/view.html.php. Does not really matter as long as in gets called in the same manner
$dispatcher->trigger( 'onBeforeCategoryListingLoad', array( & $filters, & $order, & $this) );
.

Please Log in or Create an account to join the conversation.

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
12 years 9 months ago #20635

Yes. We already made the change everywhere.

Please Log in or Create an account to join the conversation.

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
12 years 9 months ago #20649

Thanks.

Please Log in or Create an account to join the conversation.

Time to create page: 0.066 seconds
Powered by Kunena Forum