limit products to 1 category

  • Posts: 108
  • Thank you received: 6
10 years 4 months ago #163198

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.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 4 months ago #163211

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

echo $this->categoryType->displayMultiple('data[product][categories]', @$this->product->categories, '', $this->rootCategory);
If you are replacing by
$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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 108
  • Thank you received: 6
10 years 2 months ago #169910

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.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 2 months ago #169922

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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

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