Display Products Only when they have image(s)
14 years 10 months ago #31335
by webarts
Display Products Only when they have image(s) was created by webarts
Hi,
I am interested in implementing a solution to display the product only if there is an image assigned on it and also there is a value in the weight field.
Can you identify the files from the front end that the list of products is build and that we can add the check
Thanks in advance
I am interested in implementing a solution to display the product only if there is an image assigned on it and also there is a value in the weight field.
Can you identify the files from the front end that the list of products is build and that we can add the check
Thanks in advance
Please Log in or Create an account to join the conversation.
14 years 10 months ago #31360
by nicolas
Replied by nicolas on topic Re: Display Products Only when they have image(s)
The easiest is to add your check in the listing function of the file components/com_hikashop/views/product/view.html.php
But the best would be to implement your change as a hikashop plugin by implementing the onBeforeProductListingLoad(&$filters) event:
www.hikashop.com/en/support/documentatio...reProductListingLoad
But the best would be to implement your change as a hikashop plugin by implementing the onBeforeProductListingLoad(&$filters) event:
www.hikashop.com/en/support/documentatio...reProductListingLoad
Please Log in or Create an account to join the conversation.
14 years 9 months ago #31824
by webarts
Replied by webarts on topic Re: Display Products Only when they have image(s)
Hi Nicolas,
Thanks for the guidance.
I have implemented this with the option of creating a new plugin and using the onBeforeProductListingLoad(&$filters) method.
I have added the new query on the filter $filters[] = 'b.product_weight > 0';
I have tested this and it works. The problem is that it also works in the backend
Can the plugin be restricted to perform this in the front end only?
Thanks
Thanks for the guidance.
I have implemented this with the option of creating a new plugin and using the onBeforeProductListingLoad(&$filters) method.
I have added the new query on the filter $filters[] = 'b.product_weight > 0';
I have tested this and it works. The problem is that it also works in the backend
Can the plugin be restricted to perform this in the front end only?
Thanks
Please Log in or Create an account to join the conversation.
14 years 9 months ago #31849
by nicolas
Replied by nicolas on topic Re: Display Products Only when they have image(s)
Sure. Just use that code:
$app =& JFactory::getApplication();
if($app->isAdmin()) return;
$app =& JFactory::getApplication();
if($app->isAdmin()) return;
Please Log in or Create an account to join the conversation.
14 years 9 months ago #32013
by webarts
Replied by webarts on topic Re: Display Products Only when they have image(s)
Hi Nikolas,
Thanks for the help once again. It worked
Now regarding the image/no image part which seems a bit more complicated. As explained I want to use the same restriction when the product does not have an image assigned to it (do not show the product, same as weight).
Browsing on the database I can see that images are stored in the "hikashop_file" table with filetype = "product". In addition "file_ref_id" points to the products table. I am guessing I need to do an Inner Join either:
a. In the plugin: Is it possible to return somehow an Inner Join and not only extra condition (Probably not)
b. Somewhere in the view.html.php: Can you suggest the places and maybe the correct way
I am thinking of introducing a new variable "c" in addition to "a" and "b" but I have some difficulties identifiying all the places I need to fill it in
Thanks
Thanks for the help once again. It worked
Now regarding the image/no image part which seems a bit more complicated. As explained I want to use the same restriction when the product does not have an image assigned to it (do not show the product, same as weight).
Browsing on the database I can see that images are stored in the "hikashop_file" table with filetype = "product". In addition "file_ref_id" points to the products table. I am guessing I need to do an Inner Join either:
a. In the plugin: Is it possible to return somehow an Inner Join and not only extra condition (Probably not)
b. Somewhere in the view.html.php: Can you suggest the places and maybe the correct way
I am thinking of introducing a new variable "c" in addition to "a" and "b" but I have some difficulties identifiying all the places I need to fill it in
Thanks
Please Log in or Create an account to join the conversation.
14 years 9 months ago #32041
by nicolas
Replied by nicolas on topic Re: Display Products Only when they have image(s)
a. Ah yes. I didn't thought about that. You won't be able to add a left join via a plugin. So you would indeed have to modify directly the query in view.html.php
You can just do like that:
$on.=' LEFT JOIN #__hikashop_file AS c ON b.product_id=c.file_ref_id AND c.file_type=\'product\' ';
and add your condition:
$filters[]='c.file_id>0';
You can just do like that:
$on.=' LEFT JOIN #__hikashop_file AS c ON b.product_id=c.file_ref_id AND c.file_type=\'product\' ';
and add your condition:
$filters[]='c.file_id>0';
Please Log in or Create an account to join the conversation.
14 years 9 months ago #32114
by webarts
Replied by webarts on topic Re: Display Products Only when they have image(s)
Thanks Nikolas,
This worked!
This worked!
Please Log in or Create an account to join the conversation.
Time to create page: 0.171 seconds