Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Synchronize.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
20  private $context;
21 
25  private $synchronizer;
26 
30  private $jsonFactory;
31 
37  public function __construct(
38  Context $context,
39  Synchronizer $synchronizer,
40  JsonFactory $jsonFactory
41  ) {
42  parent::__construct($context);
43  $this->context = $context;
44  $this->synchronizer = $synchronizer;
45  $this->jsonFactory = $jsonFactory;
46  }
47 
64  public function execute()
65  {
66  $resultJson = $this->jsonFactory->create();
67 
68  try {
69  $productsData = $this->getRequest()->getParam('ids', []);
70  $typeId = $this->getRequest()->getParam('type_id', null);
71  $this->synchronizer->syncActions($productsData, $typeId);
72  } catch (\Exception $e) {
73  $resultJson->setStatusHeader(
74  \Zend\Http\Response::STATUS_CODE_400,
75  \Zend\Http\AbstractMessage::VERSION_11,
76  'Bad Request'
77  );
78  }
79 
80  return $resultJson->setData([]);
81  }
82 }
$productsData
Definition: products.php:19
__construct(Context $context, Synchronizer $synchronizer, JsonFactory $jsonFactory)
Definition: Synchronize.php:37