Display the storefront name in the category drop down menu
In cs-cart if you have similar category names on multiple storefronts it can be hard to know which one to select when adding new products or similar. This is a minor modification such that when suggested categories pop-up in the drop down menu the storefront they belong to is displayed in bracket.
Thank you for your message.
After some research, I've found that there is no option to implement such a modification without changing core files. Below, you can find the instructions on how to apply the requested modification.
- Navigate to the app/controllers/backend/categories.php file of your installation
- Find the following part of the code:
$objects = array_values(array_map(static function ($category) use ($view, $company_id, $item_template) { $view->assign('category', $category); $parents_path = []; foreach ($category['parents'] as $parent) { $parents_path[] = $parent['category']; } return [ 'id' => $category['category_id'], 'text' => $category['category'], 'data' => [ 'id' => $category['category_id'], 'company' => $category['company'], 'parents_path' => implode(' / ', $parents_path), 'url' => fn_url('categories.update?category_id=' . $category['category_id']), 'name' => $category['category'], 'disabled' => $company_id && !empty($category['company_id']) && $company_id !== (int) $category['company_id'], 'content' => $view->fetch("views/categories/components/{$item_template}.tpl") ] ]; }, $categories_data));
and replace it with the following:$storefront_repository = Tygh::$app['storefront.repository']; $objects = array_values(array_map(static function ($category) use ($view, $company_id, $item_template, $storefront_repository) { $view->assign('category', $category); $parents_path = []; foreach ($category['parents'] as $parent) { $parents_path[] = $parent['category']; } $storefront = $storefront_repository->findById($category['storefront_id']); return [ 'id' => $category['category_id'], 'text' => $category['category'], 'data' => [ 'id' => $category['category_id'], 'company' => $category['company'], 'parents_path' => implode(' / ', $parents_path), 'url' => fn_url('categories.update?category_id=' . $category['category_id']), 'name' => $category['category'], 'disabled' => $company_id && !empty($category['company_id']) && $company_id !== (int) $category['company_id'], 'content' => $view->fetch("views/categories/components/{$item_template}.tpl"), 'mve_name' => isset($storefront->name) ? $storefront->name : 'Common', ] ]; }, $categories_data));
- After that, navigate to the design/backend/templates/addons/my_changes/overrides/views/categories/components/picker directory of your CS-Cart installation. Create the folders if they do not currently exist in your installation.
- Put the file from the attachments in this directory
- Make sure that the My changes add-on is installed and activated in the administration panel of your store.
- Clear the cache of your installation and check the result.
After that, all the categories that are assigned to a particular storefront only will have the names of the storefronts near to the name of the category itself. Otherwise, if a category is common - it will show 'Common' word instead.