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;
use Webkul\Magento2Bundle\Services\Magento2Connector;
use Webkul\Magento2Bundle\Traits\ApiEndPointsTrait;
$obj = new \Webkul\Magento2Bundle\EventListener\AkeneoVersionsCompatibility;
$obj->checkVersionAndCreateClassAliases();
/**
* Add products to magento2 Api
*
......@@ -15,6 +17,7 @@ use Webkul\Magento2Bundle\Traits\ApiEndPointsTrait;
* @copyright 2010-2017 Webkul pvt. ltd.
* @license https://store.webkul.com/license.html
*/
abstract class BaseWriter implements \StepExecutionAwareInterface
{
use StepExecutionTrait;
......
......@@ -43,6 +43,7 @@ class ProductQueueWriter extends ProductWriter
}
$parameters = $this->getParameters();
$this->initialise();
$storeMappings = $this->getStoreMapping();
$storeSettings = $this->connectorService->getOtherSettings();
$this->channel = $this->getChannelScope($this->stepExecution);
......@@ -67,6 +68,7 @@ class ProductQueueWriter extends ProductWriter
switch ($item[PropertiesNormalizer::FIELD_MAGENTO_PRODUCT_TYPE]) {
case 'simple':
$product = [self::AKENEO_ENTITY_NAME => $item];
$this->addProduct($product);
$this->stepExecution->incrementSummaryInfo('added_to_queue');
break;
......@@ -106,15 +108,23 @@ class ProductQueueWriter extends ProductWriter
protected function addProduct($productData)
{
if (!empty($productData)) {
unset($productData['product']['main_image_data']);
/* similar data in all store view */
if ($this->storeViewCode === $this->defaultStoreViewCode) {
$baseData = $this->checkProductAndModifyData($productData, 'all');
if (!empty($baseData)) {
$productAddUrl = $this->oauthClient->getApiUrlByEndpoint('addProductQueue', 'all');
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) {
$info = $this->oauthClient->getLastResponseInfo();
if (isset($info['http_code']) && $info['http_code'] == 404) {
throw new \Exception('RabbitMQ Module not found on magento2 server.');
}
......
......@@ -381,6 +381,7 @@ class ProductWriter extends BaseWriter implements \ItemWriterInterface
}
if (!empty($formatted['custom_attributes'])) {
$attributeMappings = !empty($attributeMappings) ? $attributeMappings : [];
$formatted['custom_attributes'] = $this->modifyOptionValues($formatted['custom_attributes'], $attributeMappings);
foreach ($formatted['custom_attributes'] as $index => $value) {
......@@ -519,7 +520,7 @@ class ProductWriter extends BaseWriter implements \ItemWriterInterface
foreach ($attr['value'] as $singleValue) {
$attributeOption = $this->getMappingByCode($singleValue. '(' . $attribute->getCode() . ')', 'option');
if ($attributeOption) {
if ($this->magentoVersion < "2.3") {
if (version_compare($this->magentoVersion, "2.3", "<")) {
$attributeOptionValue[] = $attributeOption->getExternalId();
} else {
$attributeOptionValue .= ',' . $attributeOption->getExternalId();
......
......@@ -33,7 +33,14 @@ class CredentialController extends Controller
} else {
$credential = new CredentialConfig();
}
$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();
$connectorService = $this->get('magento2.connector.service');
......
......@@ -51,6 +51,8 @@ class Magento2Extension extends Extension
$loader->load('data_sources.yml');
$loader->load('cli_commands.yml');
$loader->load('rabbitmq.yml');
$loader->load('jobs.yml');
$loader->load('steps.yml');
$loader->load('readers.yml');
......
......@@ -47,7 +47,8 @@ services:
- '@pim_catalog.repository.channel'
- '@pim_catalog.repository.attribute'
- '@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'
webkul_magento2.processor.rabbitmq.magento_normalization.product:
......@@ -58,7 +59,8 @@ services:
- '@pim_catalog.repository.attribute'
- '@akeneo_storage_utils.doctrine.object_detacher'
- '@pim_connector.processor.bulk_media_fetcher'
- '@?pim_catalog.values_filler.product'
# - '@?pim_catalog.values_filler.product'
- '@pim_catalog.product_model.fill_missing_values'
- '@router'
- '@magento2.connector.service'
......
......@@ -288,3 +288,5 @@ magento2.duplicateCategory.name.title: Are Duplicate Category Name Available in
magento2.duplicateCategory.name.tooltip: Matched Category named will be update.
configurable_product_status: Configurable Product Status
pim_enrich.entity.attribute.property.visual_swatch: Export attribute as Visual Swatch
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
'storeViews' => '/rest/V1/store/storeViews',
'storeConfigs' => '/rest/V1/store/storeConfigs',
'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',
'getAttributeSets' => '/rest/{_store}/V1/products/attribute-sets/sets/list?searchCriteria[pageSize]=50',
'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