magento2-connector-community
magento2-connector-community copied to clipboard
re-enable disabled products in magento2
trafficstars
What does this solve?
- import a product from akeneo in magento2, works fine,
- 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
ping @dnd-rodstar @Dnd-Gimix
Running into the same problem for one of our clients. Thanks!
Unbelievably this still isn't solved? Have to recreate this patch for the latest connector version now...
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) {