Skip to content

Instantly share code, notes, and snippets.

@unlocomqx
Last active November 12, 2020 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unlocomqx/fcc0a46cfb543e064af8b9ee9f6a8403 to your computer and use it in GitHub Desktop.
Save unlocomqx/fcc0a46cfb543e064af8b9ee9f6a8403 to your computer and use it in GitHub Desktop.
public static function findValue($items, $value)
{
/** @var GridColumn[]|GridRow[] $item_values */
$item_values = array_values($items);
$count = count($item_values);
if (isset($item_values[0]) && $value <= $item_values[0]->value) {
return $item_values[0]->id;
}
for ($i = 0; $i < $count - 1; $i++) {
if ($value > $item_values[$i]->value && $value <= $item_values[$i + 1]->value) {
return $item_values[$i + 1]->id;
}
}
return null;
}
@unlocomqx
Copy link
Author

unlocomqx commented Nov 12, 2020

--> copy to /modules/dynamicproduct/classes/models/grids/Grid.php
--> screenshot: https://scr.prestalife.net/sc5v1i1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment