emartech / magento2-extension

Emarsys Magento2 Extension
MIT License
11 stars 9 forks source link

Environment emulation nesting is not allowed #24

Closed alexmtch closed 1 year ago

alexmtch commented 2 years ago

Version

1.14.5 but can be reproduced on latest

Description of the issue

Magento throw in log : "Environment emulation nesting is not allowed"

Caused by

Emartech\Emarsys\Helper\DataSource::getAllOptions

image

Workaround

public function getAllOptions($sourceModels, $storeIds)
{
    foreach ($storeIds as $storeId) {
        $this->optionValues[$storeId] = [];
        $this->startEmulation($storeId)
            ->getAllOptionsByStore($sourceModels, $storeId)
            ->stopEmulation();
    }

    return $this->optionValues;
}

Here is my .patch

--- a/vendor/emartech/emarsys-magento2-extension/Helper/DataSource.php 2022-04-28 09:20:38.000000000 +0200
+++ b/vendor/emartech/emarsys-magento2-extension/Helper/DataSource.php 2022-04-28 09:20:38.000000000 +0200
@@ -42,9 +42,9 @@
         foreach ($storeIds as $storeId) {
             $this->optionValues[$storeId] = [];
             $this->startEmulation($storeId)
-                 ->getAllOptionsByStore($sourceModels, $storeId);
+                ->getAllOptionsByStore($sourceModels, $storeId)
+                ->stopEmulation();
         }
-        $this->stopEmulation();

         return $this->optionValues;
     }