Get Free Audit

Big Day Release: Prestashop Category Attributes

Jul 22, 2013

311 Alex Simonchik

Big Day Release: Prestashop Category Attributes

Prestashop Category Attributes module is created for developers. It helps assign various attributes to categories. This, in turn, allows various manipulations with categories and attributes assigned. For instance, it’s possible to output CMS to a category page, output CMS categories to a product page, display categories on a page with CMS, display categories on manufacturer pages, display manufacturers on a category page and much more.

Key features:

  • Assigning attributes to categories
  • Many types of attributes available
  • Easy to manipulate with attributes
  • Guide for developers

How does it help developers?

Attributes can be as follows: products, categories, cms, CMS category, manufacturer, bool, textаreа with lang, textаreа without lang, file.

The fields of the following types: product, category, cms, CMS category retain ID of selected entities in the following format: id1-id2-id3- . Bool-type fields store either 0 or 1. Language fields store a serialized array of this type:


[1] => “mother”

[2] => “maman”


Where 1 and 2 are id_lаng. The isNоtLаng fields store data without any transformations. The file-type fields store the name for the image which is located on the server under the path: img/belvg_categoryattributes/category_#/filename , where # – id_category

In order to assign attributes to categories, go to Modules -> Belvg Category Fields and click Add new.

Enter attribute key name and back office name. Select the type of the assigned attribute. Select if it’s required and displayed on front end.

Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

Go to Catalog -> Categories and select the required category. Click the Edit button. Assign options to attributes.

In order to get results from a database you can use the following functions:

  • getValueByAdminName($id_category, $admin_name, $visibility_check = FALSE, $fullPath = FALSE)
  • getDataByBoolAdminName($admin_name, $visibility_check = FALSE)

Let’s describe 2 examples which will help better understand how to get data.

As first example we will use the menu which has been customized with the help of our module. While the second one is an absolutely new module, written from scratch, which will obtain categories on the basis of the “bool”-type field. To make both of them functional you should install the BelVG Category Attributes module and create relevant attributes:

  • menu_product – product-type attribute for the menu
  • admin_bool – bool-type attribute for Home Categories

$string_products = CategoryFields::getContext()->getValueByAdminName($category->id_category, ‘menu_product’, TRUE); – this way we obtain a collection of products for a certain category, where:

$category->id_category –  category id,

menu_product – attribute name,

TRUE – determines if it is necessary to verify visibility for this module. $fullpath – this is another optional parameter which you may need if you are working with a file-type attribute. If it is set as true, full path to a file will be returned.

Menu front end:

This is the frontend of the Home Categories module. It receives data in the following way: $data = CategoryFields::getContext()->getDataByBoolAdminName(‘admin_bool’, TRUE); The attribute admin_bool determines which categories should be displayed on the homepage.

Read the user guide to see how the Category Attributes module works.

Every time you need help with your PrestaShop store, we are here to provide you with the best services.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *