Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: Can’t import categories with numeric value
Status | Resolved |
Add-on / Version | DataGrab 4.2.2 |
Severity | |
EE Version | 7.2.9 |
Gauthier De Paoli
May 09, 2023When trying to import categories with numeric value (like 518, 001, 900, etc.) the datagrab_models threats these values as “cat_id” and not category values.
The magic occurs in datagrab_model.php:1806 in function findAndCreateCategories();
Repeatedly, it is written // Assume numeric categories are cat_id’s
Would it be possible to fix that ? Is it a
A possible solution would be to change the “is_numeric” function comparaison by a stricted one is_int() since is_numeric(‘001’) === TRUE but is_int(‘001’) === FALSE
BoldMinded (Brian)
May 09, 2023
Can you share an example of what your import file looks like?
Gauthier De Paoli
May 09, 2023
Please find an exemple here : https://pastebin.com/8kNjiqpL
It’s the content of a .csv file
BoldMinded (Brian)
May 11, 2023
So after thinking about this a bit more I’m not sure what the solution is. Using is_int() assumes that the value is an actual integer, and coming from an XML or JSON file where someone might have it quoted means is_int() will fail, which is why it’s using is_numeric(). Even in your example the numbers are quoted, so I’m assuming is_int() is going to fail. If I make a change like this it could likely break a lot of people’s imports.
BoldMinded (Brian)
May 11, 2023
I just double checked old builds of DataGrab, prior to me owning it, and it’s been this way for a _long_ time. I hesitate to make this sort of change.
Gauthier De Paoli
May 11, 2023
Hey Brian,
You’re right. Every value coming from the CSV/XML file will always be a string so is_int() will always return false.
A non-breaking change would be to add a configuration option for each category configuration row
=> Allow cell value to be a category_id (default: yes)
The condition :
```
if ($this->settings[‘config’][‘allow_numeric_value_to_be_category_id’] && is_numeric($cat)) {
$entry_categories[] = $cat;
} else {
...
}
```
BoldMinded (Brian)
May 11, 2023
Gauthier, the next comment will have a link to a new build, but it’s a beta version of v5 that isn’t public yet. Version 4 is in code freeze and not getting anymore additions or bug fixes. You can read the docs at https://docs.boldminded.com/datagrab/docs/version-5.0
BoldMinded (Brian)
May 11, 2023
Comment has been marked private.
Gauthier De Paoli
May 11, 2023
Comment has been marked private.