cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.3.4 BUG Undefined Offset Error

Magento 2.3.4 BUG Undefined Offset Error

I am using Magento 2.3.4 ver, i am getting the following error if i try to apply a filter,

 

Error Screenshot  - https://i.stack.imgur.com/IIYET.png

 

Error:

Exception #0 (Exception): Notice: Undefined offset: -298 in /var/www/html/test/vendor/magento/framework/Search/Dynamic/Algorithm.php on line 302

How to solve this issue? Is it a configuration error?

 

Source Code :

https://codebunk.com/b/2171100144809/

32 REPLIES 32

Re: Magento 2.3.4 BUG Undefined Offset Error

Hello @Aveeva ,

Sorry to inform but it's a pre-found bug in Magento which is fixed in 2.4:

https://github.com/magento/magento2/issues/22792

 

you can just get the changes which they have resolved :

https://github.com/magento/magento2/commit/db69693bd929bd8665015ff6d9b6a3845584aa0b

 

you can copy the new changes for that fix but make sure it is not dependent on any code which was added in Magento 2.4, just give it a try if works !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Magento 2.3.4 BUG Undefined Offset Error

@gaurav_harsh1  As you know my error file : /vendor/magento/framework/Search/Dynamic/Algorithm.php

 

Which file code i need to update in https://github.com/magento/magento2/commit/db69693bd929bd8665015ff6d9b6a3845584aa0b

 

Thank You.

Re: Magento 2.3.4 BUG Undefined Offset Error

@Aveeva 

 

Replace all code to https://github.com/magento/magento2/blob/db69693bd929bd8665015ff6d9b6a3845584aa0b/lib/internal/Magen...

 

If it works for you, then make sure you override this Class, not to keep change in vendor, but for testing, just copy whole file and replace code.

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Magento 2.3.4 BUG Undefined Offset Error

@gaurav_harsh1 It's working, is it okay change in core file?

Re: Magento 2.3.4 BUG Undefined Offset Error

@Aveeva 

No, you should create preference in your Custom Module, to create preference simply add this line to your di.xml file of your module/extension.

<preference for="Magento\Framework\Search\Dynamic\Algorithm" type="[VENDOR]\[EXTENSION]\Search\Dynamic\Algorithm" />

Now, create the class [VENDOR]\[EXTENSION]\Search\Dynamic\Algorithm and add all the code of that file which you have replaced.

 

It will work !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Magento 2.3.4 BUG Undefined Offset Error

@gaurav_harsh1  I am new to preference, help me if i wrong,

Module :

 

app/code/Gta/Solver/etc/di.xml

<?xml version="1.0"?>
 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Framework\Search\Dynamic\Algorithm" type="Gta\Solver\Search\Dynamic\Algorithm" />
</config>

 

 

app/code/Gta/Solver/etc/module.xml

<?xml version="1.0"?>
	<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    	<module name="Gta_Solver" schema_version="0.0.1" setup_version="0.0.1"></module>
</config>

app/code/Gta/Solver/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Gta_Solver',
    __DIR__
);

app/code/Gta/Solver/Search/Dynamic/Algorithm.php

code : https://justpaste.it/7f2zx

 

 

 

Re: Magento 2.3.4 BUG Undefined Offset Error

@Aveeva 

 

Everything is correct except namespace in Algorithm class.

namespace should be 

namespace Gta\Solver\Search\Dynamic;

make sure you run di:compile after everything and cache flush.

Let me know if it works for you. 

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Magento 2.3.4 BUG Undefined Offset Error

@gaurav_harsh1  I am getting error, 

 

1 exception(s):
Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Framework\Search\Dynamic\Algorithm\Improved

 

Re: Magento 2.3.4 BUG Undefined Offset Error

@Aveeva 

 

Please run :

php bin/magento setup:di:compile
php bin/magento c:f

and then refresh the browser.

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy