enanobots / m2-datapatchcreator-simpledata

Open Software License 3.0
10 stars 2 forks source link

Error in format of import #1

Open markshust opened 3 years ago

markshust commented 3 years ago

When trying to import the home page from sample data, this error occurs:

Argument 2 passed to Magento\Cms\Model\GetPageByIdentifier::execute() must be of the type int, array given, called in /var/www/html/vendor/markshust/magento2-module-simpledata/Api/Cms/SimplePage.php on line 86#0 /var/www/html/vendor/markshust/magento2-module-simpledata/Api/Cms/SimplePage.php(86): Magento\Cms\Model\GetPageByIdentifier->execute('home', Array)
#1 /var/www/html/app/code/MarkShust/MyData/Setup/Patch/Data/CmsPageHome.php(13): MarkShust\SimpleData\Api\Cms\SimplePage->save(Array)
#2 /var/www/html/vendor/magento/framework/Setup/Patch/PatchApplier.php(162): MarkShust\MyData\Setup\Patch\Data\CmsPageHome->apply()

This is because the SimpleData module requires the store_id be an int, not an array. The output from this module is:

                'store_id' => [
                    0 => '0',
                ],

When it should be:

                'store_id' => 0,

Unfortunately, the logic in SimpleData must be matched to an existing entity, so the following line is executed to grab the current data:

$page = $this->getPageByIdentifier->execute($identifier, $storeId);

This relies on a single store id. I think this module needs to look for the currently active store id, and pull that in as an int.

That said, when importing the downloaded file, it appears the patch script executed, but the content was not updated. I haven't had time to debug this yet, but it may make sense to install a fresh M2 install with Sample Data and test this out by changing something on the home page.

Otherwise very cool module, this will be tremendously useful 👍

enanobots commented 3 years ago

@markshust thanks for reporting. Data is exported using var_export for object data, might require few tweaks for multistore setup :-)

markshust commented 3 years ago

Just an FYI, even when I change it to a single 0, it executes the patch script, but the value for content does not update.

enanobots commented 3 years ago

this content bug will be worked on the main repository.