macopedia / magmi-m2

Magmi GitHub, see branch magento2 for a version compatible with Magento 2
113 stars 53 forks source link

fix to make work with php8.1 #103

Closed cbtrident closed 1 year ago

cbtrident commented 2 years ago

this work but some can be improve more like the date/time for files but it is it is importing and it just the need to look better but am not sure how to improve that but it working

hazzy commented 1 year ago

If it helps anyone else, I found another issue with engines/magmi_productimportengine.php runing under php 8.1

It issues a warning :-

PHP Warning: Trying to access array offset on value of type int in ..../magmi/engines/magmi_productimportengine.php on line 1869

My code change to fix the issue is to add a test to see if $item["qty"] is actually an array

           // if magmi_qty_absolute flag is not set, then use standard "relative" qty parsing.
            if (!isset($item["magmi_qty_absolute"]) || $item["magmi_qty_absolute"] == 0) {
                // test for relative qty
                //  PHP 8.1 change - test for array - we get an error is $item["qty"] is not an array 
                if (is_array($item["qty"])) {
                  if ($item["qty"][0] == "+" || $item["qty"][0] == "-") {
                     $relqty = getRelative($item["qty"]);
                  }
                } 
cbtrident commented 1 year ago

thanks for that Hazzy will add your change to my branch will test the date change later as am not using php8.1 right now had other problem but think now they fixed i could use but anyway i will give this branch alive till the main guys are back

Nofear262 commented 1 year ago

Just tested it, and it seems to work. However the import process does not generate a process bar. It is just a static page. I can only cancel, wich does nothing or go back to previous page, but the process seem to do it's work in the back-end.

On the magmi page i have this error: Deprecated: Optional parameter $dorewrite declared before required parameter $store is implicitly treated as a required parameter in /magento/magmi/plugins/extra/itemprocessors/itemindexer/otfindexer.php on line 232

thanks for making it work in php 8.1 !

cbtrident commented 1 year ago

lol that will cost you :-P

hazzy commented 1 year ago

All for the good of the public!

cbtrident commented 1 year ago

anyway thanks, be nice if the main people do the fix but least we got something that work still other error to fix but right now dont have much time to cehck

hazzy commented 1 year ago

@Nofear262 I had a look at your error. See https://php.watch/versions/8.0/deprecate-required-param-after-optional

I could not find anywhere in the Magmi code that the builProductUrlRewrite function is called but you might like to check.

If that is the case then you can fix the issue by changing the order of the parameters in the function

viz on line 232:

public function builProductUrlRewrite($pid, $store, $dorewrite=false )

If it is called, then the calling scripts will need to be changed of course to reflect the modified parameter order

John

scratch that! - it is called on line 347 of the otfindexer.php script so that line needs to be changed to reflect the modified parameter order thus

    $purlk = $this->builProductUrlRewrite($pid, $store, $dorewrite );
cbtrident commented 1 year ago

ok done the small changes hope it right

Nofear262 commented 1 year ago

Thanks Hazzy, I indeed found out that chaninging the order of params solved the issue. But i am not a coder at all. So i will definately change line 347 also. Thank you very much.

Also the process page started working yesterday out of the blue. We imported +2500 prices and stock, very happy with that.

I looked for days on Github to find this thread, so i hope the original magmi 2.x version gets updated !

onedolphin commented 1 year ago

Hey, I'm not a coder, where can I get this update and try it on php 8.1? Thanks to all

cbtrident commented 1 year ago

Hey, I'm not a coder, where can I get this update and try it on php 8.1? Thanks to all

https://github.com/cbtrident/magmi-m2 is my site for this but hope soon it be pull

onedolphin commented 1 year ago

Thank you. This is for Magento 2 right?

cbtrident commented 1 year ago

for php 8.x and works with latest magento

onedolphin commented 1 year ago

Awesome, will try, thanks!

onedolphin commented 1 year ago

I have been trying to use the new one but without success, it shows everytime NO FILE and I have used the same settings as old Magmi... any idea?

tmotyl commented 1 year ago

took your change @cbtrident and added some fixes. merged to magento2 branch. Thanks!

cbtrident commented 1 year ago

thanks

hazzy commented 1 year ago

Thanks from me too!

onedolphin commented 1 year ago

Sorry still not working for me, it shows NO FILE :(

hazzy commented 1 year ago

Sorry still not working for me, it shows NO FILE :(

How about a screenshot? Hard to help on not much info

onedolphin commented 1 year ago

Sure, will try to attach 2 here. Link below. Thanks for the help.

https://ibb.co/4TdNqrK https://ibb.co/nMWMwZf

cbtrident commented 1 year ago

is your filesystem path right did you make sure permision are correct to the file system for magmi and did you save your new profile after you setup as it best to copy and name to a name you like in my case i did to zfs then change the setting. i i think you should not play with default

hazzy commented 1 year ago

@onedolphin the NO FILE error comes from magmi_progress.php when it can't find the log file "progress.txt" in the "state" folder.

onedolphin commented 1 year ago

Hi, thanks for the help but still don't find the problem. I copy same of the errors in the log. I have not modified the default profile, I created a new one. I'm uploading the file and extracting and permissions are the same as always, I always installed Magmi this way and worked but this version is doing something different.

Here a part of error in the log file. Below this one is an error in the interface.

[23-Jan-2023 17:04:00 UTC] PHP Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /home/do/magmi/engines/magmi_productimportengine.php on line 1922 [23-Jan-2023 17:10:26 UTC] PHP Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /home/do/magmi/engines/magmi_productimportengine.php on line 1922 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: Optional parameter $dorewrite declared before required parameter $store is implicitly treated as a required parameter in /home/do/magmi/plugins/extra/itemprocessors/itemindexer/otfindexer.php on line 232 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/do/magmi/plugins/base/general/reindex/options_panel.php on line 21 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/do/magmi/plugins/inc/magmi_plugin.php on line 146 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/do/magmi/web/magmi_web_utils.php on line 6 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/do/magmi/web/magmi_web_utils.php on line 9 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/do/magmi/plugins/inc/magmi_plugin.php on line 146 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/do/magmi/web/magmi_web_utils.php on line 6 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/do/magmi/web/magmi_web_utils.php on line 9 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/do/magmi/plugins/inc/magmi_plugin.php on line 146 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/do/magmi/web/magmi_web_utils.php on line 6 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/do/magmi/web/magmi_web_utils.php on line 9 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/do/magmi/plugins/inc/magmi_plugin.php on line 146 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /home/do/magmi/web/magmi_web_utils.php on line 6 [23-Jan-2023 17:12:15 UTC] PHP Deprecated: addslashes(): Passing null to parameter #1 ($string) of type string is deprecated in /home/do/magmi/web/magmi_web_utils.php on line 9 [23-Jan-2023 17:13:00 UTC] PHP Deprecated: Function strftime() is deprecated in /home/do/magmi/web/ajax_gettime.php on line 3 [23-Jan-2023 17:13:00 UTC] PHP Parse error: syntax error, unexpected token "public" in /home/do/magmi/engines/magmi_productimportengine.php on line 1922

Error in interface:

Deprecated: Optional parameter $dorewrite declared before required parameter $store is implicitly treated as a required parameter in /home/do/magmi/plugins/extra/itemprocessors/itemindexer/otfindexer.php on line 232

cbtrident commented 1 year ago

Please test the main code now as it in main code now and what php you using

onedolphin commented 1 year ago

Sorry what do you mean main code? I set php 8.1 and then set again 7.4

tmotyl commented 1 year ago

@onedolphin please use branch "magento2" which is a main/default branch of this repository. Clone the repository and checkout to magento2 branch (or git pull, if you're already on this branch).

onedolphin commented 1 year ago

@tmotyl Sorry I'm a newbie here. The site says the last update was 3 days ago. This is the one that will fix it? https://github.com/macopedia/magmi-m2/archive/refs/heads/magento2.zip

tmotyl commented 1 year ago

Yes, you can download zip and unpack it, but its not the best way to install plugins in Magento world. Anyway, check if you have changes from this commit in place: https://github.com/macopedia/magmi-m2/commit/aa9f2c38ea4c132c828c162a58850b3bf21cc690

onedolphin commented 1 year ago

Sorry @tmotyl when I download the zip file is not the most updated files? Now when I downloaded a new one I cannot access magmi at all, I modified as usual the magmi.ini but cannot access, still shows I need to create a new magmi.ini file. Sorry new here wat github, still trying to see how this works. What do you mean to not install plugins in Magento, I'm only installing Magmi...

cbtrident commented 1 year ago

what os you install are you using apache or nginx as there diffrent way to setup the more information will help us to help you

onedolphin commented 1 year ago

@cbtrident I'm using LiteSpeed. I will be happy to provide any other details.

cbtrident commented 1 year ago

@onedolphin what os is that running on please i will setup a system to test but never seen LiteSpeed

onedolphin commented 1 year ago

@cbtrident The OS is AlmaLinux 8.7.

onedolphin commented 1 year ago

Any ideas?

cbtrident commented 1 year ago

sorry waiting for my test key for LiteSpeed.

can you check what php you using pleasse doing php -v i have to say i hate this linux i know it based on centos but not fun for me

onedolphin commented 1 year ago

Hi @cbtrident, please see what I got:

PHP 8.1.14 (cli) (built: Jan 11 2023 17:12:45) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.14, Copyright (c) Zend Technologies with Zend OPcache v8.1.14, Copyright (c), by Zend Technologies

onedolphin commented 1 year ago

Help please...

onedolphin commented 1 year ago

@onedolphin the NO FILE error comes from magmi_progress.php when it can't find the log file "progress.txt" in the "state" folder.

@hazzy Can I just create a progress.txt file? I did but now just shows plugins and startup below.