How to show product list with additional condition

  • Posts: 252
  • Thank you received: 1
9 years 1 month ago #247077

-- HikaShop version -- : HikaShop Business 2.6.3
-- Joomla version -- : 3.5

Hi,
I have created a custom filed, how can I add condition of this vendor input field to content module to show the specific product list?

Best Regards
Scott

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

  • Posts: 84313
  • Thank you received: 13702
  • MODERATOR
9 years 1 month ago #247079

Hi,

I'm not sure I understand you ? You want to only display the products of a specific vendor in a module ?
Or the products of the vendor whenj you display the module on the vendor page ?
Or something else ?

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

  • Posts: 252
  • Thank you received: 1
9 years 1 month ago #247158

Hi Nicolas,
I have two stores share the same product data, some products just show on one of the stores.
So I created one custom field to separate them. Is there a way that I can show the products list with the custom field condition?

Best Regards

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

  • Posts: 84313
  • Thank you received: 13702
  • MODERATOR
9 years 1 month ago #247165

Hi,

So you want to add a condition in the products listing to restrict the products on the listing based on a custom product field value.

When you edit a menu item via the Joomla menu manager or a module via the Joomla modules manager, you can see that there are no options to restrict the listing of products based on a custom field value.
What you can do though is to create a filter on that custom field via the menu System>Filters.
Then, turn on the "redirect POST mode" setting of the HikaShop configuration.
Then, on your products listing, you should see that filter at the top if you have the "filters" display setting turned on on your menu item settings page.
And when you use the filter, you'll see that the URL changes. So, you can actually use the URL for the value of the custom field you want as a new "external URL" menu item to get a new menu item which directly displays a prefiltered products listing.

The following user(s) said Thank You: ::REZA::, twscott

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

  • Posts: 6
  • Thank you received: 0
9 years 2 weeks ago #249058

Hi
I need to do the exact same thing twscott is trying to do. I have created a custom field "Free Shipping" and I want to show a module containing the products with this custom field set to "1" in the first page on my website, so I can't use the way you suggested in the last post.
Also I don't want to make a category "Free Shipping" and assign products to it and show the products with selecting category in content module, because probably in future there will be a lot more custom fields and it's not reasonable to make a category for each custom field.
So I tried to make a little changes to hikashop content module and make a new module out of it to involve custom fields to restrict products. I tried to change add my custom field name to $params in mod_hikashop.php, but didn't succeed. :(

So what should I do to make it happen?

As I think this is kind of a important feature, maybe you want to place it in your todo list ;)

Thanks in advance for your help

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

  • Posts: 84313
  • Thank you received: 13702
  • MODERATOR
9 years 2 weeks ago #249062

Hi,

If you know programming then it's not difficult.
You need to create a small joomla plugin of the group "hikashop", and implement the "onBeforeProductListingLoad" trigger:
www.hikashop.com/support/documentation/6...reProductListingLoad
That way you can add the condition on the query loading the products on listings of HikaShop really easily like that:

$filters[] = 'b.custom_field_column_name = 1';
Then, if you want to do that filter on one specific module, set a global variable in your module override like:
$_SESSION['my_module']=1;
before the call to the hikashop_getLayout function and then:
$_SESSION['my_module']=0;
after it, so that you can add a check like that at the beginning of the onBeforeProductListingLoad function of your plugin:
if(!@$_SESSION['my_module']) return;

Alternatively, if you're not a developer, you can create a "free shipping" category and create some mass actions to add/remove the category automatically on the products when the custom field is changed:
www.hikashop.com/support/documentation/167-massaction-form.html
So it's still possible to do it quite easily.
You can have thousands of categories in HikaShop, that's not really a problem. And you can have these custom field categories under an unpublished category so that it doesn't display on your frontend categories listings. So I don't see a problem with doing it like that using categories.

Last edit: 9 years 2 weeks ago by nicolas.
The following user(s) said Thank You: ::REZA::

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

  • Posts: 6
  • Thank you received: 0
9 years 2 weeks ago #249098

Hi

Thank you!
I did the session and plugin way you suggested. Now I can select every custom field I want and the plugin do the rest for me and it's perfect.
The reason I do not want to make a category for each custom field is, I want to make it as simple as possible for my client to just edit products.
This way maybe there's no need to add a new feature to mod_hikashop :whistle: :whistle:

Anyway, great support as always.
Thanks again.

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

Time to create page: 0.070 seconds
Powered by Kunena Forum