magento2-connector-community icon indicating copy to clipboard operation
magento2-connector-community copied to clipboard

re-enable disabled products in magento2

Open guido7171 opened this issue 5 years ago • 4 comments
trafficstars

What does this solve?

  1. import a product from akeneo in magento2, works fine,
  2. disable same product in akeneo and import again. works fine. 3. enable same product in akeneo and import > FAIL > product status stays disabled.

When product exists in akeneo but is disabled. Set product status with new akeneo status value (enabled), and not with old magento status value

guido7171 avatar Sep 08 '20 07:09 guido7171

ping @dnd-rodstar @Dnd-Gimix

peterjaap avatar Nov 11 '20 10:11 peterjaap

Running into the same problem for one of our clients. Thanks!

JKingma avatar Nov 11 '20 11:11 JKingma

Unbelievably this still isn't solved? Have to recreate this patch for the latest connector version now...

peterjaap avatar Dec 02 '22 14:12 peterjaap

Looks like this is the patch for the current version, I also changed the value to enabled in the new completeness part;

diff --git a/Job/Product.php b/Job/Product.php
index 0084ea9..03e6476 100644
--- a/Job/Product.php
+++ b/Job/Product.php
@@ -1808,7 +1808,7 @@ class Product extends JobImport
         /** @var string[] $pKeyColumn */
         $pKeyColumn = 'a._entity_id';
         /** @var string[] $columnsForStatus */
-        $columnsForStatus = ['entity_id' => $pKeyColumn, '_entity_id', '_is_new' => 'a._is_new'];
+        $columnsForStatus = ['entity_id' => $pKeyColumn, '_entity_id', '_is_new' => 'a._is_new', 'enabled' => 'a.enabled'];
         /** @var mixed[] $mappings */
         $mappings = $this->configHelper->getWebsiteMapping();
         /** @var string[] $columnsForCompleteness */
@@ -1937,7 +1937,7 @@ class Product extends JobImport
                 $status = $this->setProductStatuses($attributeCodeSimple, $mappings, $connection, $tmpTable, 'simple');
             } else {
                 while (($row = $oldStatus->fetch())) {
-                    $valuesToInsert = ['_status' => $row['value']];
+                    $valuesToInsert = ['_status' => $row['enabled']];
 
                     $connection->update($tmpTable, $valuesToInsert, ['_entity_id = ?' => $row['_entity_id']]);
                 }
@@ -1979,7 +1979,7 @@ class Product extends JobImport
         }
         while (($row = $oldConfigurableStatus->fetch())) {
             /** @var string $status */
-            $status = $row['value'];
+            $status = $row['enabled'];
             // Update existing configurable status scopable
             if ($this->configHelper->getProductStatusMode() === StatusMode::STATUS_BASED_ON_COMPLETENESS_LEVEL) {
                 foreach ($mappings as $mapping) {

peterjaap avatar Dec 02 '22 14:12 peterjaap