Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

First iteration tasks

Eugene Tulika edited this page Jan 24, 2018 · 7 revisions

Base information: https://github.com/magento-engcom/bulk-api/wiki

This document describes main concepts of new functionality on lower level

General

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.

Tasks:

Task 1: Introduce extension point in REST request processing

  1. 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;
}
  1. Inject this interface to `\Magento\Webapi\Controller\Rest
$responce = $this->requestProcessor->process($request, $responce);
  1. 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);
}
  1. 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

Task 2: Introduce Async request processors

  1. 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.

  1. Processor should set into response UID

  2. Register processor in DI

<item key="async" type="string">AsyncProcessor</item>

Task 3: Publish mechanism for Product

  1. 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.
  1. Describe configuration on communication.xml Generally, maybe we will expand this declaration. Know we use current declaration.

  2. 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

  1. Cover functionality with API functional tests (for checking result we can use some temporal new object in test namespace)

Task 4: Consumer for Product

  1. 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

  1. Cover functionality with API functional tests

Task 5: Introduce Web API for \Magento\Framework\Bulk\BulkStatusInterface

Other open questions:

  1. Why do we need external_id for products? Product has SKU (system independent identifier)
  2. Investigate possibility to remove async prefix in url (maybe use some custom HTTP header)
Clone this wiki locally