-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix additional headers and root category selection #9
Open
paugnu
wants to merge
1
commit into
macopedia:master
Choose a base branch
from
paugnu:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paugnu
commented
Apr 5, 2020
- The additional headers generated array can generate empty values (which lend later to warning or errors). We use array_filter to remove empty values.
- If no parent id is selected, instead of automatically selecting '2' as category root, we check what the category root for the default store view is. We could even ask this value as parameter (TODO)
* The additional headers generated array can generate empty values (which lend later to warning or errors). We use array_filter to remove empty values. * If no parent id is selected, instead of automatically selecting '2' as category root, we check what the category root for the default store view is.
Hi |
tmotyl
requested changes
Jun 10, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default store id should not be hardcoded
oviliz
added a commit
to oviliz/CategoryImporter
that referenced
this pull request
Dec 2, 2023
Fix the following when attempting to import a CSV from CLI: ``` There is an error in app/code/Macopedia/CategoryImporter/Console/Command/CategoriesCommand.php at line: 159 array_key_exists(): Argument macopedia#2 ($array) must be of type array, null given#0 app/code/Macopedia/CategoryImporter/Console/Command/CategoriesCommand.php(159): array_key_exists() macopedia#1 vendor/symfony/console/Command/Command.php(298): Macopedia\CategoryImporter\Console\Command\CategoriesCommand->execute() macopedia#2 vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run() macopedia#3 vendor/magento/framework/Interception/Interceptor.php(138): Macopedia\CategoryImporter\Console\Command\CategoriesCommand\Interceptor->___callParent() macopedia#4 vendor/magento/framework/Interception/Interceptor.php(153): Macopedia\CategoryImporter\Console\Command\CategoriesCommand\Interceptor->Magento\Framework\Interception\{closure}() macopedia#5 generated/code/Macopedia/CategoryImporter/Console/Command/CategoriesCommand/Interceptor.php(23): Macopedia\CategoryImporter\Console\Command\CategoriesCommand\Interceptor->___callPlugins() macopedia#6 vendor/symfony/console/Application.php(1040): Macopedia\CategoryImporter\Console\Command\CategoriesCommand\Interceptor->run() macopedia#7 vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand() macopedia#8 vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun() macopedia#9 vendor/symfony/console/Application.php(171): Magento\Framework\Console\Cli->doRun() macopedia#10 bin/magento(23): Symfony\Component\Console\Application->run() macopedia#11 {main} ``` According to ChatGPT :) The error is due to the `array_key_exists` function being called on a null array. Specifically, the issue is in the `mapHeaders` method on line 159. This method is supposed to map headers from the file to row keys, but there seems to be an issue with the way it's implemented. To fix this issue, we can modify the `mapHeaders` method to handle the case where `$item` is not found in the `$headers` array. In this version, I replaced the nested loop with a call to `in_array` to check if the current `$item` exists in the `$headers` array. If it does, the corresponding key is set in the `$headersMap` array.
oviliz
added a commit
to oviliz/CategoryImporter
that referenced
this pull request
Dec 2, 2023
Error: There is an error in app/code/Macopedia/CategoryImporter/Console/Command/CategoriesCommand.php at line: 159 array_key_exists(): Argument macopedia#2 ($array) must be of type array, null given#0 app/code/Macopedia/CategoryImporter/Console/Command/CategoriesCommand.php(159): array_key_exists() macopedia#1 vendor/symfony/console/Command/Command.php(298): Macopedia\CategoryImporter\Console\Command\CategoriesCommand->execute() macopedia#2 vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run() macopedia#3 vendor/magento/framework/Interception/Interceptor.php(138): Macopedia\CategoryImporter\Console\Command\CategoriesCommand\Interceptor->___callParent() macopedia#4 vendor/magento/framework/Interception/Interceptor.php(153): Macopedia\CategoryImporter\Console\Command\CategoriesCommand\Interceptor->Magento\Framework\Interception\{closure}() macopedia#5 generated/code/Macopedia/CategoryImporter/Console/Command/CategoriesCommand/Interceptor.php(23): Macopedia\CategoryImporter\Console\Command\CategoriesCommand\Interceptor->___callPlugins() macopedia#6 vendor/symfony/console/Application.php(1040): Macopedia\CategoryImporter\Console\Command\CategoriesCommand\Interceptor->run() macopedia#7 vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand() macopedia#8 vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun() macopedia#9 vendor/symfony/console/Application.php(171): Magento\Framework\Console\Cli->doRun() macopedia#10 bin/magento(23): Symfony\Component\Console\Application->run() macopedia#11 {main} The error you're encountering is due to the `array_key_exists` function being called with a null value as the second argument on line 159. This suggests that `$this->headersMap` is null or not an array. To fix this issue, you should ensure that `$this->headersMap` is initialized as an array before using it in `array_key_exists`. You can modify the mapHeaders method to include an initialization for `$this->headersMap`. Here's an updated version of the mapHeaders method. By adding the line `$this->headersMap = [];` at the beginning of the method, you ensure that `$this->headersMap` is always an array, even if it wasn't initialized before. This should resolve the `array_key_exists` error.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.