How to work with item types after 17 Dec 2018 commit
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 7
- Joined: 16 Jul 2018, 17:50
How to work with item types after 17 Dec 2018 commit
Hi there,
I have a project with an older version of Aimeos in which I was using getTypeId() and getTypeName() item methods.
I was trying to use the same methods on a new project with an updated version of Aimeos but I noticed that these methods has been removed in this commit
What is the proper way to get the same results with the current version?
Here is an example of a piece of code where I'm using these methods:
Thanks.
I have a project with an older version of Aimeos in which I was using getTypeId() and getTypeName() item methods.
I was trying to use the same methods on a new project with an updated version of Aimeos but I noticed that these methods has been removed in this commit
What is the proper way to get the same results with the current version?
Here is an example of a piece of code where I'm using these methods:
Code: Select all
$options = [];
$variantAttributes = $variantProduct->getRefItems('attribute', null, 'variant');
foreach ($variantAttributes as $variantAttribute) {
if (empty($options[$variantAttribute->getTypeId()])) {
$options[$variantAttribute->getTypeId()] = [
'attribute_id' => $variantAttribute->getTypeId(),
'attribute_code' => $variantAttribute->getType(),
'values' => [],
'label' => $variantAttribute->getTypeName(),
'code' => $variantAttribute->getType(),
'position' => 0
];
}
$options[$variantAttribute->getTypeId()]['values'][] = [
'value_index' => $variantAttribute->getId(),
'label' => $variantAttribute->getLabel()
];
}
Re: How to work with item types after 17 Dec 2018 commit
Instead of "$variantAttribute->getTypeId()" you should use "$variantAttribute->getType()" now. The getTypeName() method has been removed and you should translate the attribute type code with:
Code: Select all
$this->translate( 'client/code', $variantAttribute->getType() );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 7
- Joined: 16 Jul 2018, 17:50
Re: How to work with item types after 17 Dec 2018 commit
Ok. I see that type id has been substituted by the type code in relationships.
What's happens if you change the type code of an attribute type that has already been related to attributes, these attributes to products and so?
As I see, the related attribute remains with the old code
What's happens if you change the type code of an attribute type that has already been related to attributes, these attributes to products and so?
As I see, the related attribute remains with the old code
Re: How to work with item types after 17 Dec 2018 commit
Yes, the codes stay the same if you change the values in the type table. The behavior is now consistent to document oriented systems like Solr or ElasticSearch.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star