mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Optimize product name special characters handling in OFF external barcode lookup plugin
This commit is contained in:
@@ -52,11 +52,14 @@ class OpenFoodFactsBarcodeLookupPlugin extends BaseBarcodeLookupPlugin
|
||||
|
||||
// Use the localized product name, if provided
|
||||
$name = $data->product->product_name;
|
||||
if (isset($data->product->$productNameFieldLocalized))
|
||||
if (isset($data->product->$productNameFieldLocalized) && !empty($data->product->$productNameFieldLocalized))
|
||||
{
|
||||
$name = $data->product->$productNameFieldLocalized;
|
||||
}
|
||||
|
||||
// Remove non-ASCII characters in product name (whyever a product name should have them at all)
|
||||
$name = preg_replace('/[^\x20-\x7E]/', '', $name);
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'location_id' => $locationId,
|
||||
|
Reference in New Issue
Block a user