Skip to main content

limit products to 1 category

12 years 4 months ago #163198 by christofu
Hi,

can a product be limited to 1 category?

i.e. when someone adds a product they only have the option of adding it to a singular category?

thanks

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

12 years 4 months ago #163211 by Jerome
Replied by Jerome on topic limit products to 1 category
Hi,

For your HikaMarket questions, please use the HikaMarket forum section.

There is no restriction on the number of categories a product can have but you can create it manually.
In the "productmarket | form" view of HikaMarket, you will find the line
Code:
echo $this->categoryType->displayMultiple('data[product][categories]', @$this->product->categories, '', $this->rootCategory);
If you are replacing by
Code:
$cat = 0; if(!empty($this->product->categories)) { $cats = array_keys($this->product->categories); $cat = reset($cats); } echo $this->categoryType->displayMultiple('data[product][categories]', @$this->product->categories, '', $this->rootCategory);
And it will display just one category (the first one).

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

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

12 years 2 months ago #169910 by christofu
Hi Jerome,

is there an easy way of only allowing one category to be entered into the category form - I understand the above code will just take the first category entered?

I think will get confused if they are still able to enter multiple categories.

(plz feel free to move this to its correct category or I can restart this in the hikamarket area)

thanks

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

12 years 2 months ago #169922 by Jerome
Replied by Jerome on topic limit products to 1 category
Hi,

Well, you can call the function "displaySingle" instead of the function "displayMultiple", but at this moment you will have to change the input name to "data[product][categories][]" otherwise the rest of the HikaMarket code won't appreciate.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

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

Moderators: Obsidev
Time to create page: 0.046 seconds
Powered by Kunena Forum