You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to import Commerce Product element types that have a "Commerce Products" field that provides a "Related Products" functionality for each product.
It seems that the Related Commerce Product field only accepts a string at the moment and, when providing an array of product Ids, I'm getting the error trim(): Argument #1 ($string) must be of type string, array given - CommerceProducts.php: 110.
Would it be possible that the Commerce Product entry types accept an array similar to what Entries, Assets and Categories field do so it can import multiple related products for each product?
I might be missing something though, so feel free to point me in the right direction if that's the case.
Thanks heaps!
Additional info
Craft version: 4.8.9
PHP version: 8.2.10
Database driver & version: MySQL 8.0.33
Plugins & versions: 5.4.0
The text was updated successfully, but these errors were encountered:
You can already import multiple related products at once. That’s true for any field that extends BaseRelationField, such as Commerce Products, Assets, Entries, etc.
So related_products in your feed is an empty array, your feed maps relatedProducts to related_products, and you have “Default Product” selected too - is that correct?
I have raised a PR to improve this, but for now, if you change your feed to use null instead of an empty array for the related_products (and any other relational fields that are not supposed to have a value), it should work as expected.
Description
I am trying to import Commerce Product element types that have a "Commerce Products" field that provides a "Related Products" functionality for each product.
It seems that the Related Commerce Product field only accepts a string at the moment and, when providing an array of product Ids, I'm getting the error
trim(): Argument #1 ($string) must be of type string, array given - CommerceProducts.php: 110
.Would it be possible that the Commerce Product entry types accept an array similar to what Entries, Assets and Categories field do so it can import multiple related products for each product?
I might be missing something though, so feel free to point me in the right direction if that's the case.
Thanks heaps!
Additional info
The text was updated successfully, but these errors were encountered: