Skip to content

Change in behaviour of Category Model in recent EE update #5060

@jcogs-design

Description

@jcogs-design

Description of the problem
We use a custom add-on on a site to synchronise data from an external ERP system with Channel Entries.
The external ERP data includes information about the 'category' of each item, which we map to EE Categories.
During this synchronisation process data on existing categories is abstracted from EE using a standard model call - vis:

self::$erp_category_group = ee('Model')->get('CategoryGroup')->filter('group_name', 'ERP Categories')->filter('site_id', ee()->config->item('site_id'))->first();

A category tree is abstracted from this return:

$existing_category_tree   = self::$erp_category_group->getCategoryTree(ee()->tree);

The category tree is setup for iteration - vis:

$iterator = $existing_category_tree->preorder_iterator();

This iterator is then looped through and various information is retrieved.
The looping sets up a variable $category for each iteration containing one of the categories in the tree - vis:

        foreach ($iterator as $item) {
            $category = $item->data();

Data is retrieved from the $category object (a stdClass).

Code we wrote and has been in use since 2023 pulls various attributes - e.g.:

$existing_category_array[$current_level_1_cat_url_title] = ['cat_id' => $category->cat_id, 'cat_name' => $category->cat_name, 'cat_description' => $category->cat_description, 'erp_cat' => $erp_category_field_value];

This code is now failing with a php error reporting that the property $category->cat_description is not defined.

We have implemented a work-around to avoid this:

$existing_category_array[$current_level_1_cat_url_title] = ['cat_id' => $category->cat_id, 'cat_name' => $category->cat_name, 'cat_description' => isset($category->cat_description) ? $category->cat_description : '', 'erp_cat' => $erp_category_field_value]

But it does seem that the 'cat_description' value is no longer appearing in the model output.

This implies the EE CategoryGroup model specification has changed recently, but as far as I am aware there was no announcement of this breaking change.

How To Reproduce
Hopefully the report is sufficient description.

Environment Details:

  • Version: 7.5.17
  • PHP Version 8.3.27

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions