Product options changing order

  • Posts: 17
  • Thank you received: 0
7 years 6 months ago #269224

-- HikaShop version -- : 3.7
-- Joomla version -- : 3.6.5

On a few of our products we use Options with characteristics to allow customers to configure final product.
To create the order the options appear as on the product page we can drag and drop the options in the backend product window then save.

Problem: Once saved the list reverts back to the numbered order of the options. So if you go in and make a change the option list order changes as well unless you resort them every time before you hit save.

view.xscreenshot.com/725581f60efe4d6c9afd04b099b2f6d4

Have tried a few things but cant get the ordering to "stick" through a product save. Any help?

Cheers

Last edit: 7 years 6 months ago by Sheldon.

Please Log in or Create an account to join the conversation.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
7 years 6 months ago #269259

Hi,

I'm not able to reproduce the problem on my end with the 3.0.1 version of HikaShop (note that the 3.7 version doesn't exist yet so I'm not sure which version you're actually using, or if you're coming from the future :p) and I don't remember anyone pointing at a bug there, at least in the last few years.
So I guess it will require more tests from you.
If you try with another browser, does it work ?
Do you have any javascript error on the page (you can see them with the javascript console of your browser) ?
Do you use a WYSIWYG editor different than the default one (TinyMCE) ? If you switch to the default one, does that help ?
Did you configure any mass action in the menu System>Mass actions ? They can potentially mess with the saving process.
Do you have any custom plugin on your website ?

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
7 years 6 months ago #269317

Your right! Joomla 3.6.5/hikashop 3.0.1
Tried firefox and chrome and IE, all the same results .I did have to change the order of the products to enable them to be displayed in the preferred list order...
I will talk with my excellent developer and see what he thinks...



Thank you for your kind and timely response Nicolas!
(Sent to you from the future :o)

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 3
7 years 6 months ago #269415

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];
        }
      }

The following user(s) said Thank You: nicolas, Jerome, nico.van.leeuwen

Please Log in or Create an account to join the conversation.

  • Posts: 290
  • Thank you received: 22
7 years 6 months ago #269439

Hi everybody,

I can confirm this issue in my website (Joomla 3.7.0 with Hikashop 3.0.1).

Thank you remotelyyours for the great explanation.

Please Log in or Create an account to join the conversation.

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
7 years 6 months ago #269452

Hi,

@remotelyyours :
Thank you !
That was indeed a great help.
I've added the patch on our end.

@nico.van.leeuwen :
We've added the patch on our end. You can either apply what @remotelyyours proposed or download the install package on our website and install it on yours to get the fix.

Please Log in or Create an account to join the conversation.

Time to create page: 0.085 seconds
Powered by Kunena Forum