I have a test script which should update products:
use MagentoFrameworkAppBootstrap;
require __DIR__ . '/app/bootstrap.php';
error_reporting(E_ERROR | E_PARSE);
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('adminhtml');
$productRepository = $objectManager->get('MagentoCatalogModelProductRepository');
$file = __DIR__.'/import.xlsx';
$inputFileType = PhpOfficePhpSpreadsheetIOFactory::identify($file);
/** Create a new Reader of the type that has been identified **/
$reader = PhpOfficePhpSpreadsheetIOFactory::createReader($inputFileType);
/** Load $inputFileName to a Spreadsheet Object **/
$spreadsheet = $reader->load($file);
$workSheet = $spreadsheet->getActiveSheet();
$highestRow = $workSheet->getHighestRow();
echo 'Highest row: '.$highestRow.PHP_EOL;
$row =3;
while($row <= $highestRow){
echo 'Entering loop '.$row.PHP_EOL;
if(trim($workSheet->getCell('C'.$row)->getValue())):
echo 'Getting value '.trim($workSheet->getCell('C'.$row)->getValue()).PHP_EOL;
$childIds = [];
try {
$product = $productRepository->get(trim($workSheet->getCell('A'.$row)->getValue()));
echo 'Getting product '.trim($workSheet->getCell('A'.$row)->getValue()).PHP_EOL;
} catch (MagentoFrameworkExceptionNoSuchEntityException $e){
$product = null;
echo $e->getMessage();
} catch (Exception $e){
echo $e->getMessage();
$product = null;
}
.....
}
the console output using gdb is following:
Starting program: /usr/local/php74/bin/php ./testr.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Highest row: 212
Entering loop 3
Getting value Anza Radiatorkwast Extra
Program received signal SIGSEGV, Segmentation fault.
0x000000000076f6ef in mysqlnd_mysqlnd_pfc_receive_pub (pfc=0x7fffecaa4500, vio=0x7fffecb4fc80, buffer=0x7fffff7ff020 "", count=4, conn_stats=0x7fffecbab7e0, error_info=0x7fffa2089920)
at /usr/local/directadmin/custombuild/php-7.4.33/ext/mysqlnd/mysqlnd_protocol_frame_codec.c:319
319 /usr/local/directadmin/custombuild/php-7.4.33/ext/mysqlnd/mysqlnd_protocol_frame_codec.c: No such file or directory.
as you can see from output the script halts at:
$product = $productRepository->get(trim($workSheet->getCell(‘A’.$row)->getValue()));
any idea what is wrong here