Limit category submission to subcategories only

  • Posts: 21
  • Thank you received: 0
9 years 10 months ago #160617

Hello

We have a tree structure with categories and subcategories, categories will be used as titles only and we would like vendors to be able to add products only in subcategories

Could you explain how to achieve this ?

And if not possible is there any way to group subcategories by tag or keyword ?

Thanks
Jean

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

  • Posts: 26025
  • Thank you received: 4005
  • MODERATOR
9 years 10 months ago #160618

Hi,

We have some explanations about the category structure in the "vendor tutorial".
www.hikashop.com/support/documentation/1...-multi-tutorial.html

You can change the "vendor root category" in HikaMarket, this category root can be dynamic but it can also be "fixed".
When the vendor root category is fixed, it will be the same for every vendors in the store.
But you will be able to change this "vendor root category" per vendor, in the vendor edition page in the backend.

In the future, we want to provide this option also available though the ACL, so the "vendor root category" could be dynamic depending the vendor groups.

Joomla tags are for the moment only accessible for the HikaShop products.
But it is possible to specify keywords in the HikaShop categories.
After that, I don't see how (where) you want to group the sub categories by keywords.

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: 21
  • Thank you received: 0
9 years 10 months ago #160631

Thanks for the explanations but we want to achieve something else :

We have a tree structure like this :
- Vehicles
--- autos
---motos
-real estate
---house selling
---house renting

We want vendors to be able to add products in autos, motos, house selling and house renting but not in the main categories titles vehicles and real estate

Ideally these categories titles in hikashop should never have products, being only titles

But I did not see the way to structure categories like this

Any hint ?

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

  • Posts: 26025
  • Thank you received: 4005
  • MODERATOR
9 years 10 months ago #160659

Bonjour,

Nous prévoyons d'améliorer le système de "catégorie vendeur racine" afin de pouvoir proposer plusieurs catégories.
Ainsi le vendeur pourra sélectionner sa catégorie racine (ainsi que toutes ses sous catégories) mais également les catégories supplémentaires sélectionnées (avec les sous catégories aussi).

Pour votre cas, je ne sais pas si une option d'inclusion ou d'exclusion serait le plus pratique.
Il est prévu d'avoir de l'inclusion de nouvelles catégories dans une prochaine version d'HikaMarket (initialement prévu pour la 1.5.0 / 1.5.1).
Au niveau de l'exclusion, le tout pourrait être dans la configuration d'HikaMarket et surchargeable au niveau vendeur (et donc au niveau groupe avec les ACL).

Dans l'immédiat, je ne pourrais que vous conseiller d'utiliser un plugin afin de filtrer les catégories sélectionnées par les vendeurs.
Via le trigger HikaShop "onBeforeProductUpdate" et "onBeforeProductCreate" il est possible de modifier les catégories qui seront sauvegardées. Ainsi si un vendeur dans le front-end ajoute des catégories non autorisées.

Cordialement,


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: 21
  • Thank you received: 0
9 years 10 months ago #160706

Bonjour Jérôme

En fait l'idée est de pouvoir regrouper des sous catégories avec un titre et de ne pas pouvoir ajouter d'éléments dans ce titre qui ne sert qu'à fluidifier le système et faciliter la compréhension de l'utilisateur.
Peut être est il possible dans Hikashop de regrouper des sous-catégories avec un titre ou sous un intitulé ? ou de jouer sur les ACL de la catégorie parente dans hikashop ? Je n'ai pas trouvé comment.

Pour répondre à votre question, une option d'exclusion me semble le plus approprié.

Dans l'immédiat est il possible d'interdire globalement l'ajout de produits dans ces catégories de regroupement via Hikashop au lieu de passer par une solution pour chaque vendeur ?

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

  • Posts: 26025
  • Thank you received: 4005
  • MODERATOR
9 years 10 months ago #160792

Hi,

(I will continue in English, it could help other users).

For a feature short delay, the best is to use a custom plugin.
To filter the product categories, the trigger "onBeforeProductUpdate" and "onBeforeProductCreate" are perfect.

So you can use a plugin like this (raw and untested code).
Plugin : hikamarket / categoryexclusion / categoryexclusion.php

<?php
class plgHikamarketCategoryexclusion extends JPlugin [

	public function onBeforeProductCreate(&$product, &$do) {
		$this->categoryFiltering($product);
	}
	public function onBeforeProductUpdate(&$product, &$do) {
		$this->categoryFiltering($product);
	}

	public function categoryFiltering(&$product) {
		if(empty($product->categories))
			return;
		$app = JFactory::getApplication();
		if($app->isAdmin())
			return;
		$init = defined('HIKAMARKET_COMPONENT');
		if(!$init)
			return;

		// The excluded categories (hard coded in the plugin but can be read from the plugin configuration with a little more code)
		$excluded_categories = array(10, 15, 20);

		// Remove the excluded categories
		foreach($product->categories as $k => $v) {
			if(in_array((int)$v, $excluded_categories))
				unset($product->categories[$k]);
		}
	}
}
Let me know if you have feedback.

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: 21
  • Thank you received: 0
9 years 10 months ago #161205

Well the plugin instals well and works fine.

The problem is that categories are still displayed when adding a product in the category list, even if the category is excluded after saving the product.
This will lead to wrong behaviors from customers still adding in main categories as they should not
Can you add some lines to also avoid to display main titles when adding or editing a product ?

I have written the plugin like attached

Attachments:

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

  • Posts: 26025
  • Thank you received: 4005
  • MODERATOR
9 years 10 months ago #161262

Hi,

Yes I understand but unfortunately there is no trigger in HikaMarket to filter the categories.
I wanted to add one but the structure returned by the category selector type is a encoded json string ; it won't be easy to manage in a trigger.
I would prefer to have a nice trigger where the categories will be passed as a usable array, but it requires some big modification in the type class in order to change the way that the json string is generated.

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.068 seconds
Powered by Kunena Forum