mc12345678 / EasyPopulate-4.0

Data import and export module for Zencart 1.3.x and 1.5.x
GNU General Public License v2.0
10 stars 8 forks source link

Products names and descriptions are mandatory on priceQty file ? #46

Open mesnitu opened 6 years ago

mesnitu commented 6 years ago

Importing the priceQty file, now it seems that the product names / description have to be present. PHP Warning: array_key_exists() expects parameter 2 to be array, null given in C:\xampp\htdocs\vhosts\testes.local\admin\easypopulate_4_import.php on line 1946

 if (isset($v_products_name[$lang_id]) || array_key_exists($lang_id, $v_products_name)) {
                  $_POST['products_name'][$lang_id] = $v_products_name[$lang_id];
                }
                if (isset($v_products_name[$lang_id_code]) || array_key_exists($lang_id_code, $v_products_name)) {
                  $_POST['products_name'][$lang_id_code] = $v_products_name[$lang_id_code];
                }

Is this correct ?

mesnitu commented 6 years ago

Maybe it should be if (isset($v_products_name[$lang_id]) && array_key_exists($lang_id, $v_products_name)) {

mc12345678 commented 6 years ago

Well, I have a different line 1946 in the current version of the files in here, but the result that has been seen would be expected though not desired. The assumption made for the code at this point was that $v_products_name (or $v_products_description, etc) would be defined as something including an empty array; however, somehow in the process it is not even an array. No, it should not be that both functions result in a true statement (a && b) it is that if either condition is true then continue to the internal processing understanding that the first true condition encountered will cease all other evaluations (a || b) if a is true, then there is no need to evaluate b and therefore evaluation stops. In (a && b) a must be evaluated and if true then b will be evaluated, if a is not true then b will be ignored.

So therefore: the solution to this issue is to check if the array element is set like currently written, then if it is not to evaluate if the variable is set, if it is an array and if the array element exists in the array.

At least that would appear to be the case in the fileset being used. It doesn't match the fileset I just looked at as line 1946:

               if (isset($v_products_description[$lang_id_code]) || array_key_exists($lang_id_code, $v_products_description)) {

But if everything before 1946 is the same between your version and the github version and it was an accidental incorrect copy and paste, then the solution I described above would be:

               if (isset($v_products_description[$lang_id_code]) || isset($v_products_description) && is_array($v_products_description) && array_key_exists($lang_id_code, $v_products_description)) {

But I would still want to look (again?) at why it is not an array. I know that I had chosen to make a change of some sort before, but I thought it was to keep it as an array, although that may have been based on the field existing in the import file.

Oh, no there is no expected requirement that the names/descriptions be required; however, the full language design for all portions of the code have not been updated yet either with focus having been on the full product information and then working on the other sections/arrays. That may be the cause of this issue.

mesnitu commented 6 years ago

I've downloaded the master version. You're using the https://github.com/mc12345678/EasyPopulate-4.0/tree/Next-Version/admin ? Is it stable ?

mc12345678 commented 6 years ago

No, I'm using the master version Next-Version was a branch that was added at one point to possibly make identification easier; however, the code of it seemed functional and it got sucked in. Seems stable as comments previously provided have been incorporated such that the above issue should not exist though I will likely try to test it some time today.