Commit 81809b6b by Bartosz Kubicki

Updating module with async features

parent e6151136
.idea
\ No newline at end of file
...@@ -8,6 +8,8 @@ use Webkul\Magento2Bundle\Traits\StepExecutionTrait; ...@@ -8,6 +8,8 @@ use Webkul\Magento2Bundle\Traits\StepExecutionTrait;
use Webkul\Magento2Bundle\Services\Magento2Connector; use Webkul\Magento2Bundle\Services\Magento2Connector;
use Webkul\Magento2Bundle\Traits\ApiEndPointsTrait; use Webkul\Magento2Bundle\Traits\ApiEndPointsTrait;
$obj = new \Webkul\Magento2Bundle\EventListener\AkeneoVersionsCompatibility;
$obj->checkVersionAndCreateClassAliases();
/** /**
* Add products to magento2 Api * Add products to magento2 Api
* *
...@@ -15,6 +17,7 @@ use Webkul\Magento2Bundle\Traits\ApiEndPointsTrait; ...@@ -15,6 +17,7 @@ use Webkul\Magento2Bundle\Traits\ApiEndPointsTrait;
* @copyright 2010-2017 Webkul pvt. ltd. * @copyright 2010-2017 Webkul pvt. ltd.
* @license https://store.webkul.com/license.html * @license https://store.webkul.com/license.html
*/ */
abstract class BaseWriter implements \StepExecutionAwareInterface abstract class BaseWriter implements \StepExecutionAwareInterface
{ {
use StepExecutionTrait; use StepExecutionTrait;
......
...@@ -43,12 +43,13 @@ class ProductQueueWriter extends ProductWriter ...@@ -43,12 +43,13 @@ class ProductQueueWriter extends ProductWriter
} }
$parameters = $this->getParameters(); $parameters = $this->getParameters();
$this->initialise();
$storeMappings = $this->getStoreMapping(); $storeMappings = $this->getStoreMapping();
$storeSettings = $this->connectorService->getOtherSettings(); $storeSettings = $this->connectorService->getOtherSettings();
$this->channel = $this->getChannelScope($this->stepExecution); $this->channel = $this->getChannelScope($this->stepExecution);
$this->otherSettings = $this->connectorService->getSettings(); $this->otherSettings = $this->connectorService->getSettings();
foreach ($items as $key => $mainItem) { foreach ($items as $key => $mainItem) {
$iteration = 0; $iteration = 0;
$addedProductModels = []; $addedProductModels = [];
...@@ -67,6 +68,7 @@ class ProductQueueWriter extends ProductWriter ...@@ -67,6 +68,7 @@ class ProductQueueWriter extends ProductWriter
switch ($item[PropertiesNormalizer::FIELD_MAGENTO_PRODUCT_TYPE]) { switch ($item[PropertiesNormalizer::FIELD_MAGENTO_PRODUCT_TYPE]) {
case 'simple': case 'simple':
$product = [self::AKENEO_ENTITY_NAME => $item]; $product = [self::AKENEO_ENTITY_NAME => $item];
$this->addProduct($product); $this->addProduct($product);
$this->stepExecution->incrementSummaryInfo('added_to_queue'); $this->stepExecution->incrementSummaryInfo('added_to_queue');
break; break;
...@@ -106,15 +108,23 @@ class ProductQueueWriter extends ProductWriter ...@@ -106,15 +108,23 @@ class ProductQueueWriter extends ProductWriter
protected function addProduct($productData) protected function addProduct($productData)
{ {
if (!empty($productData)) { if (!empty($productData)) {
unset($productData['product']['main_image_data']);
/* similar data in all store view */ /* similar data in all store view */
if ($this->storeViewCode === $this->defaultStoreViewCode) { if ($this->storeViewCode === $this->defaultStoreViewCode) {
$baseData = $this->checkProductAndModifyData($productData, 'all'); $baseData = $this->checkProductAndModifyData($productData, 'all');
if (!empty($baseData)) { if (!empty($baseData)) {
$productAddUrl = $this->oauthClient->getApiUrlByEndpoint('addProductQueue', 'all'); $productAddUrl = $this->oauthClient->getApiUrlByEndpoint('addProductQueue', 'all');
try { try {
$this->oauthClient->fetch($productAddUrl, is_array($baseData) ? json_encode($baseData) : $baseData, 'POST', $this->jsonHeaders); $this->oauthClient->fetch($productAddUrl,
is_array($baseData) ? json_encode($baseData) : $baseData,
'POST', $this->jsonHeaders);
} catch (\Exception $e) { } catch (\Exception $e) {
$info = $this->oauthClient->getLastResponseInfo(); $info = $this->oauthClient->getLastResponseInfo();
if (isset($info['http_code']) && $info['http_code'] == 404) { if (isset($info['http_code']) && $info['http_code'] == 404) {
throw new \Exception('RabbitMQ Module not found on magento2 server.'); throw new \Exception('RabbitMQ Module not found on magento2 server.');
} }
......
...@@ -381,6 +381,7 @@ class ProductWriter extends BaseWriter implements \ItemWriterInterface ...@@ -381,6 +381,7 @@ class ProductWriter extends BaseWriter implements \ItemWriterInterface
} }
if (!empty($formatted['custom_attributes'])) { if (!empty($formatted['custom_attributes'])) {
$attributeMappings = !empty($attributeMappings) ? $attributeMappings : [];
$formatted['custom_attributes'] = $this->modifyOptionValues($formatted['custom_attributes'], $attributeMappings); $formatted['custom_attributes'] = $this->modifyOptionValues($formatted['custom_attributes'], $attributeMappings);
foreach ($formatted['custom_attributes'] as $index => $value) { foreach ($formatted['custom_attributes'] as $index => $value) {
...@@ -519,7 +520,7 @@ class ProductWriter extends BaseWriter implements \ItemWriterInterface ...@@ -519,7 +520,7 @@ class ProductWriter extends BaseWriter implements \ItemWriterInterface
foreach ($attr['value'] as $singleValue) { foreach ($attr['value'] as $singleValue) {
$attributeOption = $this->getMappingByCode($singleValue. '(' . $attribute->getCode() . ')', 'option'); $attributeOption = $this->getMappingByCode($singleValue. '(' . $attribute->getCode() . ')', 'option');
if ($attributeOption) { if ($attributeOption) {
if ($this->magentoVersion < "2.3") { if (version_compare($this->magentoVersion, "2.3", "<")) {
$attributeOptionValue[] = $attributeOption->getExternalId(); $attributeOptionValue[] = $attributeOption->getExternalId();
} else { } else {
$attributeOptionValue .= ',' . $attributeOption->getExternalId(); $attributeOptionValue .= ',' . $attributeOption->getExternalId();
......
...@@ -33,7 +33,14 @@ class CredentialController extends Controller ...@@ -33,7 +33,14 @@ class CredentialController extends Controller
} else { } else {
$credential = new CredentialConfig(); $credential = new CredentialConfig();
} }
$data = json_decode($request->getContent(), true); $data = json_decode($request->getContent(), true);
if (isset($data['hostName'])) {
$credentialCheck = $em->getRepository(CredentialConfig::class)->findOneByHostName($data['hostName']);
if(!empty($credentialCheck)) {
return new JsonResponse([ 'hostName' => 'Host Name already used Please try another !.' ], Response::HTTP_BAD_REQUEST);
}
}
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$connectorService = $this->get('magento2.connector.service'); $connectorService = $this->get('magento2.connector.service');
......
...@@ -51,6 +51,8 @@ class Magento2Extension extends Extension ...@@ -51,6 +51,8 @@ class Magento2Extension extends Extension
$loader->load('data_sources.yml'); $loader->load('data_sources.yml');
$loader->load('cli_commands.yml'); $loader->load('cli_commands.yml');
$loader->load('rabbitmq.yml');
$loader->load('jobs.yml'); $loader->load('jobs.yml');
$loader->load('steps.yml'); $loader->load('steps.yml');
$loader->load('readers.yml'); $loader->load('readers.yml');
......
...@@ -47,7 +47,8 @@ services: ...@@ -47,7 +47,8 @@ services:
- '@pim_catalog.repository.channel' - '@pim_catalog.repository.channel'
- '@pim_catalog.repository.attribute' - '@pim_catalog.repository.attribute'
- '@pim_connector.processor.bulk_media_fetcher' - '@pim_connector.processor.bulk_media_fetcher'
- '@?pim_catalog.values_filler.product' # - '@?pim_catalog.values_filler.product'
- '@pim_catalog.product_model.fill_missing_values'
- '@pim_connector.doctrine.cache_clearer' - '@pim_connector.doctrine.cache_clearer'
webkul_magento2.processor.rabbitmq.magento_normalization.product: webkul_magento2.processor.rabbitmq.magento_normalization.product:
...@@ -58,10 +59,11 @@ services: ...@@ -58,10 +59,11 @@ services:
- '@pim_catalog.repository.attribute' - '@pim_catalog.repository.attribute'
- '@akeneo_storage_utils.doctrine.object_detacher' - '@akeneo_storage_utils.doctrine.object_detacher'
- '@pim_connector.processor.bulk_media_fetcher' - '@pim_connector.processor.bulk_media_fetcher'
- '@?pim_catalog.values_filler.product' # - '@?pim_catalog.values_filler.product'
- '@pim_catalog.product_model.fill_missing_values'
- '@router' - '@router'
- '@magento2.connector.service' - '@magento2.connector.service'
# writers # writers
webkul_magento2.writer.product.rabbitmq_api: webkul_magento2.writer.product.rabbitmq_api:
class: 'Webkul\Magento2Bundle\Connector\Writer\ProductQueueWriter' class: 'Webkul\Magento2Bundle\Connector\Writer\ProductQueueWriter'
......
...@@ -287,4 +287,6 @@ pim_enrich.export.category.data.title: FILTER THE CATEGORIES ...@@ -287,4 +287,6 @@ pim_enrich.export.category.data.title: FILTER THE CATEGORIES
magento2.duplicateCategory.name.title: Are Duplicate Category Name Available in Magento ? magento2.duplicateCategory.name.title: Are Duplicate Category Name Available in Magento ?
magento2.duplicateCategory.name.tooltip: Matched Category named will be update. magento2.duplicateCategory.name.tooltip: Matched Category named will be update.
configurable_product_status: Configurable Product Status configurable_product_status: Configurable Product Status
pim_enrich.entity.attribute.property.visual_swatch: Export attribute as Visual Swatch pim_enrich.entity.attribute.property.visual_swatch: Export attribute as Visual Swatch
\ No newline at end of file batch_jobs.default_steps.rabbitmq_product_export: Product Export(RabbitMQ)
batch_jobs.default_steps.rabbimq_product_model_export: Product Model Export(RabbitMQ)
\ No newline at end of file
...@@ -11,7 +11,7 @@ trait ApiEndPointsTrait ...@@ -11,7 +11,7 @@ trait ApiEndPointsTrait
'storeViews' => '/rest/V1/store/storeViews', 'storeViews' => '/rest/V1/store/storeViews',
'storeConfigs' => '/rest/V1/store/storeConfigs', 'storeConfigs' => '/rest/V1/store/storeConfigs',
'product' => '/rest/{_store}/V1/products/{sku}?searchCriteria=', 'product' => '/rest/{_store}/V1/products/{sku}?searchCriteria=',
'addProductQueue' => '/rest/{_store}/async/V1/add-products', 'addProductQueue' => '/rest/{_store}/async/V1/products',
'currency' => '/rest/{_store}/V1/directory/currency', 'currency' => '/rest/{_store}/V1/directory/currency',
'getAttributeSets' => '/rest/{_store}/V1/products/attribute-sets/sets/list?searchCriteria[pageSize]=50', 'getAttributeSets' => '/rest/{_store}/V1/products/attribute-sets/sets/list?searchCriteria[pageSize]=50',
'addAttributeSet' => '/rest/{_store}/V1/products/attribute-sets', 'addAttributeSet' => '/rest/{_store}/V1/products/attribute-sets',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment