I'm trying to get the customer increment_id to be included as customer_increment_id as an extension_attribute in orders when I search orders through rest/V1/ordes?searchCriteria...
I added following to my modules etc/extension_attributes.xml but it doesn't seem to work.
<extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
<attribute code="customer_increment_id" type="string">
<join reference_table="customer_entity" reference_field="entity_id" join_on_field="customer_id">
<field>increment_id</field>
</join>
</attribute>
</extension_attributes>
I have checked my permissions cleared var/generations/* var/cache/* runed magento setup:upgrade in all possible ways!
So what am I missing?
I have this extension in the same file and that one works fine searching customer via rest/V1/customer/search.
<extension_attributes for="Magento\Customer\Api\Data\CustomerInterface">
<attribute code="increment_id" type="string">
<join reference_table="customer_entity" reference_field="entity_id" join_on_field="entity_id">
<field>increment_id</field>
</join>
</attribute>
</extension_attributes>
/Thomas
1 Answer 1
I don't know how the JoinProcessor works exactly.
Anyway, following this answer I actually found out that Resource Models belonging to magento-customer inject a dependency on JoinProcessor while those belonging to magento-sales don't. I think this should explain why the attribute is working in the latter case and not in the former: in this case an explicit data loading is required (please have a look to Gift Message case). This can be done for example by using Plugins.
-
I had all forgotten about this question. I too have come to this conclution. The join processor isn't added to magento sales. To add customer increment_id to the searchresult would require some plugin or extension work.TNordkvist– TNordkvist2016年11月30日 15:04:43 +00:00Commented Nov 30, 2016 at 15:04