Order Attributes API Overview

Order Attributes API

Info
We have created a public API collection for Order Attributes module with all available queries and sample data that you can both test via our demo endpoints and copy to run local tests in your Magento environment. More details about using public collections can be found in the following FAQ post.
1. Amasty\Orderattr\Api\EntityDataRepositoryInterface - class for managing order attributes in the backend:
  1. POST /V1/amasty_orderattr/entityData, method="save" - create an attribute;
  2. PUT /V1/amasty_orderattr/entityData/:entityId, method="save" - edit an attribute;
  3. DELETE /V1/amasty_orderattr/entityData/:entityId, method="deleteById" - delete an attribute;
  4. GET /V1/amasty_orderattr/entityData, method="getById" - get information about an attribute;
  5. GET /V1/amasty_orderattr/entityData/all, method="getList" - get a list with attributes;
  6. GET /V1/amasty_orderattr/entityData/:orderId, method="getByOrderId - get information about an attribute by its ID.

2. Amasty\Orderattr\Api\CheckoutDataRepositoryInterface - class for managing order attributes on checkout for registered users:
  1. POST /V1/amasty_orderattr/checkoutData, method="save" - add an order attribute on checkout for a logged-in user.

3. Amasty\Orderattr\Api\GuestCheckoutDataRepositoryInterface - class for managing order attributes on checkout for logged-in users:
  1. POST /V1/amasty_orderattr/guestCheckoutData, method="save" -  add an order attribute on checkout for a guest.

If it is necessary to retrieve the order ID using an order attribute value in the Order Attributes API module, you need to use a GET request with the following format:  
  1. {{base_url}}/rest/all/V1/amasty_orderattr/entityData/all?searchCriteria  
The key parameters are:  
  1.  "parent_entity_type": 1 means that the order attribute is part of the order, whereas 2 means it is part of the quote  
  2.  "parent_id": 3 - if parent_entity_type is 1, then parent_id corresponds to order_id, and if it is 2, it corresponds to quote_id  

For example, to retrieve all orders where attribute_code is amasty_test_order_attr_code and attribute_value is test_2, you can use the following query:  

  1. {{base_url}}/rest/all/V1/amasty_orderattr/entityData/all?searchCriteria[filter_groups][0][filters][0][field]=amasty_test_order_attr_code&searchCriteria[filter_groups][0][filters][0][value]=test_2&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[filter_groups][1][filters][0][field]=parent_entity_type&searchCriteria[filter_groups][1][filters][0][value]=1&searchCriteria[filter_groups][1][filters][0][condition_type]=eq  

The results of this request can be seen in the screenshot 


 
This screenshot shows that orders 4 and 6 have the attribute_code amasty_test_order_attr_code with the attribute_value test_2. This is also confirmed by the order grid visible in the screenshot 



      • Related Articles

      • What Amasty extensions support API?

        Each Amasty extension that has API support, includes the etc/webapi.xml file. The webapi.xml file contains API configurations with the list of available API requests. For example, a request from the Custom Form module interface: 1 - endpoint URL; 2 - ...
      • Can I test how your modules work with API?

        Our team have created a public Postman workspace where we provide access to API collections from our modules. You can copy these API collections to test them in your own Magento installation together with our modules, and some collections can be ...
      • Order Attributes | GraphQL methods

        Queries amOrderattrAvailableAttributes (cartId: String!) description: get the list of available order attributes amOrderattrAttributesRelations description: get information about order attribute relations Mutations saveAmOrderattrValues (cartId: ...
      • I want to use your Order Attributes in scripts/customizations. How may I get their values from the code?

        To get the Order Attributes values from the code, you may use the strings below: $orderRepository = $objectManager->get('Magento\Sales\Api\OrderRepositoryInterface'); $order= $orderRepository->get(); $attr = $order->getData('');
      • Extra Fee API

        We have created a public API collection for Extra Fee module with all available queries and sample data that you can both test via our demo endpoints and copy to run local tests in your Magento environment. More details about using public collections ...