Skip to main content

Remove default category

More
12 years 11 months ago #128285 by DeeEmm
I've searched the forums and read the documentation and I'm sure that there must be a simple answer for this (and perhaps a configuration setting hidden in plain sight) but I cannot seem to find how to disable the default product category in the vendor product form.




TIA

/DM

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

More
12 years 11 months ago #128317 by Jerome
Replied by Jerome on topic Remove default category
Hi,

In the view "productmarket | form", please replace
Code:
<dd class="hikamarket_product_category"><?php echo $this->categoryType->displayMultiple('data[product][categories]', @$this->product->categories, '', $this->rootCategory); ?></dd>
By:
Code:
<dd class="hikamarket_product_category"><?php if(empty($this->product->product_id)) $this->product->categories = array(); echo $this->categoryType->displayMultiple('data[product][categories]', @$this->product->categories, '', $this->rootCategory); ?></dd>
To remove the categories when creating a new product.

Please note that even if there is not displayed category, if you save the product HikaMarket/HikaShop will set a default one. It is not possible to have a product without a least one category.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
The following user(s) said Thank You: DeeEmm

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

More
12 years 11 months ago #128332 by DeeEmm
Replied by DeeEmm on topic Remove default category
Thanks Jerome, that works great.

However, is it possible that if no category is selected that the user is prompted to add one instead of automatically assigning one?

My reasoning is as follows (perhaps a little cynical but probably fairly accurate)

- Pre-selecting a category - 90% of users will simply assume that this is normal and so they will not delete it.
- Automatically adding a category - users who forget to select a category will be unaware.

In either case I would bet that for every 100 products added I end up with 95 in the root category.

Much better to have no category automatically selected, and some basic form validation.

Is this easily achievable?

/DM

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

More
12 years 11 months ago #128363 by Jerome
Replied by Jerome on topic Remove default category
Hi,

It is but it will impact the HikaMarket core so that's not a modification that I will recommend.
In HikaMarket product class, you will find this
Code:
if(empty($product->product_id) && !count($product->categories) && !empty($rootCategory)) { $product->categories = array($rootCategory); }

Maybe the best will be to add some javascript checks in the page. So when the user wants to submit the form, some checks are made and cancel the form submission if there is something wrong.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
The following user(s) said Thank You: DeeEmm

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

More
12 years 11 months ago - 12 years 11 months ago #128382 by DeeEmm
Replied by DeeEmm on topic Remove default category
Thanks Jerome.

i ended up adding some simple javascript validation.

in productmarket / form.php I added a javascript function to detect the presence of submitted categories and added an onsubmit call to the form declaration
Code:
<script type="text/javascript"> function validateForm(){ if (document.forms["hikamarket_form"]["data[product][categories][]"] === undefined){ alert("Please Select one or more categories"); exit; } else { return; } } </script> <form action="<?php hikamarket::completeLink('product');?>" method="post" name="hikamarket_form" id="hikamarket_products_form" enctype="multipart/form-data" onsubmit="return validateForm()">

Hope this helps someone else.

/DM
Last edit: 12 years 11 months ago by DeeEmm.
The following user(s) said Thank You: Jerome, master_b

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

More
12 years 11 months ago #130406 by master_b
Replied by master_b on topic Remove default category
tnx for this and i think its good be if add that as option in market config

сайт з перекладами www.benefit.in.ua
PS. спасибо переводить Webmoney : Z207635098627 R152456839841 или ЯД 410011027999056

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

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