OpenCart Categories
Category Hierarchy
In Opencart the categories can be structured with unlimited levels. The top categories have subcategories and a subcategory has only one parent category.
In our example the category "C" is a parent to category "B" and category "B" is a subcategory to category "C" but a parent to category "A"
Category "A" is the last in the chain: C->B->A and can have only one way up A-B-C.
Category ID
Every category has its number - category_id
This number is assigned to each category automatically by OpenCart as the categories are created. For example, category "C" might get number 1, category "B" number 3, and category "A" number 8 (if you created categories from top to bottom, left to right).
Category names can be anything (they can be changed): OpenCart is working with category id, not with category name.
Products and Categories
Products can be shown in different categories.
When adding a product, you can choose to which category to be assigned.
If in the price list there is only one category, you can add it to it, or to the price list category and its parent or all parent categories.
If in the price list there are several categories that are not hierarchically related, you can add the product to them only if the category names are identical to the site categories.
Categories. Autocreate
Create categories from a file
The plugin needs to see the category hierarchy and define which category is the top category. Because it builds a category chain from top to bottom, starting with the top category.
(in the image above, the top categories are underlined with a red line).
The top categories must be created manually in the OpenCart admin panel in advance. Usually, these are the menu top categories. In this case, there are only three.
Supplier form settings
The plugin reads the price list line by line, skipping lines that do not contain an SKU or product price. Therefore, we need column 4, filled with an arbitrary number.
The contents of column 4 can be used as an SKU and as a price:
In the field "Categories", enter the column numbers separated by commas, starting with the lowest category:
Set "Action":
Save the form. Open it and click "Start". Choose your file and run the program.
When the action is performed go to the categories list page and click the button "Rebuild":
Category URLs are generated automatically. Images and metadata can be created or updated using "Tools" and "SEO template".
Create categories from an XML/YML file
Categories are created from data located at the beginning of the price list:
Warning: Line breaks between the <category and </category> tags are not allowed.
Supplier form settings
Fill in the "SKU" and "Price" fields with arbitrary numbers, and also specify the product separator in the "Separator" field in the lower-left corner of the supplier form:
Select "Action" to "Create categories" Save the form. Open it and click "Start". Choose your file and run the program.
When the action is performed go to the categories list page and click the button "Rebuild":
Category URLs are generated automatically. Images and metadata can be created or updated using "Tools" and "SEO template".
Categories. Edit
With this module, you can export the categories, edit them and then import them. Categories are exported to a spreadsheet file in Excel format, convenient for making changes.
Export Categories
- Create a supplier form and save it, or open an existing one
- Open the tab "Tools"
- Choose the action "Export categories" and click "Start"
On the server, in the admin/uploads folder will appear a file ex.xml with categories, it opens with Excel:
Each row of the table contains a specific subcategory hierarchy from the subcategory to parent categories. The odd columns (1,3,5,7....) contain category_id, and the even columns (2,4,6,8....) contain category names.
The table also contains links to category photos, meta data, URLs, and sort order. File structure:
- the image is in a column with a number 33 greater than the name of its category
- the description is in a column with a number 53 greater than its category name
- Category URL is in a column with a number 73 greater than its category name
- meta-description is in a column with a number 93 greater than its category name
- meta-keywords is in a column with a number 113 greater than its category name
- meta-title is in a column with a number 133 greater than its category name
- meta-h1 is in a column with a number 153 greater than its category name
- sort order is in a column with a number 173 greater than the name of its category
Make changes to the table (do not change category_id!) and upload category images to the folder image/catalog/category/ if you want to add category images. This folder is specially designed for storing category images.
Category Import
Upload the edited file to the server in the admin/uploads/ folder, keep the name ex.xml and xml format and perform the tool:
Category import in another site
The ex.xml file can be used to create categories on another site. To do this, it is enough to enter the following column numbers in the supplier form on another site:
In the "SKU" and "Price" fields, enter the column number 17 and perform the action:
Save the form. Open it and click "Start". Choose your file and run the program.
(read more about creating categories here)
Edit categories with "Tools".
In the "Tools" tab you will find a lot of tools to edit category URLs, metadata, and descriptions:
The tool "Fix categories SEO url" doesn't require SEO template settings. The URL is created by the category name.
The term "sub-categories" means - all categories that are nested in this one, except for itself:
Categories. SEO URL and Metadata
Category URL
When you create categories from a file, the SEO URL is created from the category name. Ex. if the category name is "Men's T-shirts", the URL will become "men-s-t-shirts"
Read more about how to create and edit the categories.
Category Meta Data
The category meta title and meta description can be generated or edited using the SEO template in the supplier form. The shortcodes are replaced by the dynamic data when the categories are created.
Read how to use the SEO Template.
If you created the categories without meta data, or they were created before the plugin installation, you can edit them using the "Tools". There are several instruments to work with categories.
If some fields are left blank in the SEO template, then these fields will not change in the categories. For example, you only need to change meta_description without changing meta_h1 and meta_title:
Categories. Category Image
The category images are an important element in the site's design and the subcategory images are also important for better navigation.
But if you have a lot of categories, it is hard to add images from admin for everyone.
Under the "Tools" tab you have two tools to add category images automatically:
The plugin will take 10 random product images from the category, or if there are no products in the category, it will take them from a subcategory. The best quality image will be assigned to the category.
Tool 1. If the category has already an image, the plugin will not replace it. Exceptions are photos that have in their name no_photo, no_image, no_thumb or no-photo, no-image, no-thumb. Such images will be replaced.
Tool 2. Replaces all category images with new ones.