-
Notifications
You must be signed in to change notification settings - Fork 3
First iteration tasks
Base information: https://github.com/magento-engcom/bulk-api/wiki
This document describes main concepts of new functionality on lower level
The main idea is creating working solution on first iteration. It helps us to:
- possibility to immediately start implementation of base part;
- discover new issues;
- unblock work for more sophisticated cases.
- Introduce new interface
RequestProcessorInterface
use Magento\Framework\Webapi\Rest\Request;
use Magento\Framework\Webapi\Rest\Response;
interface RequestProcessorInterface
{
public function process(Request $request, Response $responce): Response;
}
- Inject this interface to `\Magento\Webapi\Controller\Rest
$responce = $this->requestProcessor->process($request, $responce);
- Base implementation of RequestProcessorInterface
private $processors;
public function process(Request $request, Response $responce)
{
if (!isset($this->processors[$request->getPathInfo()])) {
throw new NotFoundException(__('Specified request does not match any route.'));
}
$processor = $this->objectmanager->get($this->processors[$request->getPathInfo()]);
$processor->process($request, $responce);
}
- Update di.xml Something like
<item key="scheme" type="string">SchemeProcessor</item>
<item key="V1" type="string">SyncProcessor</item>
Pay attention: this task was partial finished in https://github.com/magento/bulk-api-ce/pull/1/files
- Request processor should set proper Status Code
202 ACCEPTED The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place.
-
Processor should set into response UID
-
Register processor in DI
<item key="async" type="string">AsyncProcessor</item>
- Define routing between WebAPI request to the topic used by message queue publisher
- current proposal is to automatically generate topics based on routes in webapi.xml. Consumers can use webapi.xml as the source of information on which Service Contract should be invoked.
-
Describe configuration on
communication.xml
Generally, maybe we will expand this declaration. Know we use current declaration. -
Implement
Magento\Catalog\Model\SaveProductPublisherInterface
(interface name is preliminary)
- Generate UID
$bulkUID = $this->identityService->generateId(); // \Magento\Framework\DataObject\IdentityGeneratorInterface
- Create factory for operations (personal factory for each entity) and encapsulate logic of operation creating
- Schedule bulk
$result = $this->bulkManagement->scheduleBulk($bulkUID, $operations, $bulkDescription, $userId); // \Magento\Framework\Bulk\BulkManagementInterface::scheduleBulk
- Should return bulk UID
At this state, we can hardcode topic name in implementation
- Cover functionality with API functional tests (for checking result we can use some temporal new object in test namespace)
- Consumer implementation
interface Magento\Catalog\Model\ProductConsumerInterface
public function processOperations(\Magento\AsynchronousOperations\Api\Data\OperationListInterface $operationList)
In first implemenation it coul be proxy te repository
- Cover functionality with API functional tests
- Why do we need external_id for products? Product has SKU (system independent identifier)
- Investigate possibility to remove
async
prefix in url (maybe use some custom HTTP header)