Hi. Here is the problem in a more detailed way.
Before I press save I add an option
After I press save - I check my DB
When I edit the product after it, the option is not at the bottom of the list, but is at the top. So when I save the product for the second time - it's saved in the new order.
And here is the place where the things a broken.
So let's assume I'v just added the option to the bottom of the list, it's saved and I open my product to edit it.
In administrator/components/com_hikashop/views/product/tmpl/form.php;414 HS code
echo $this->nameboxType->display(
'data[product][options]',
@$this->product->options,
hikashopNameboxType::NAMEBOX_MULTIPLE,
'product',
array(
'delete' => true,
'sort' => true,
'default_text' => '<em>'.JText::_('HIKA_NONE').'</em>',
)
);
returns the list disregarding
product_related_ordering field from the DB. So my option is returned at the top of the list.
The problem is in
administrator/components/com_hikashop/classes/product.php line about 3570.
The code place is here:
$filter = array();
foreach($value as $v) {
$filter[] = (int)$v;
}
$query = 'SELECT p.* '.
' FROM ' . hikashop_table('product') . ' AS p ' .
' WHERE p.product_id IN ('.implode(',', $filter).') ';
$this->db->setQuery($query);
$products = $this->db->loadObjectList('product_id');
So
$filter array still contains the correct ordering (my option id at the bottom), but after the DB query
$products contains ordered by
product_id objects.
So my solution is to reorder the
$products after being got from the DB
So I'd replace code in line 3570
$products = $this->db->loadObjectList('product_id');
with
$products_tmp = $this->db->loadObjectList('product_id');
$products = [];
foreach ($filter as $pid)
{
if (isset($products_tmp[$pid]))
{
$products[$pid] = $products_tmp[$pid];
}
}