Display inconsistencies in back-end for variants

  • Posts: 113
  • Thank you received: 18
8 years 2 months ago #248606

-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.5.1
-- PHP version -- : 5.6.24
-- Browser(s) name and version -- : Firefox 48.02

The order of pricing levels appears to be inconsistent. On the product page, entering multiple prices works well and the price levels are consistently displayed in the order entered. When entering price levels for variants, the order changes once the record is saved. This appears to happen consistently on products with 2 or more characteristics.

The order of variants themselves changes as well when the record is saved - even records with a single characteristic.

When maintenance is needed to a product of this type, it's more difficult than it should be as records are changing order during editing - it's like trying to hit a moving target.

When editing multiple products, some simple, some with variants, the behavior seems to vary.

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 2 months ago #248673

Hi,

I've done some tests but I don't see the issue on my end.
I can create the variants and the prices in the variants and save them and they come back in the same order.
You say that it appears only in some cases ?
Could you do more tests to figure out what really makes the prices or variants dont respect the same order ?

Regarding the variants, they are automatically ordered based on the ordering of the characteristics (on the characteristics listing) and the ordering of the values (in the characteristics) unless you changed the "characteristics values ordering" setting of the HikaShop configuration.

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

  • Posts: 113
  • Thank you received: 18
8 years 2 months ago #248693

I'm able to recreate the described issue fairly easily.
I keep a clean site for testing purposes, fresh Joomla 3.62 and Hikashop 2.6.3 with sample Hikashop data installed.
Nothing else installed or modified, about the only things I've done is enable a shipping method and payment method, maybe changed currency from EUR to USD in a few places.

To recreate:
Edit the sample data's Brown Shoes product, add characteristics for Color and Shoe Size, add each combination as variants, save and close the record. Open the product again, view Variants tab and note the order. Make an edit to any of the variants and save the variant using the "Save" button beneath the list of variants. The order of the variant records will change when saved.

The issue I'm seeing with prices changing order isn't as readily recreated, but there are times when the order of presentation makes no sense to me at all: not in the order entered, not ordered by quantity, not ordered by price as shown in the attached.

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 2 months ago #248749

Hi,

The only reason I'm seeing a different order with the variants with your example is because there is no ordering set for the values in the color characteristic. Define an ordering and the ordering won't be random.
So that's what I was talking in my previous message.
If you set the ordering properly, then the variants should always be in the same order. Isn't that the case for you too ?

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

  • Posts: 113
  • Thank you received: 18
8 years 2 months ago #248757

That is not the case.
I had tested with an order set on color characteristics as well before posting the reply.

The order of variants displayed after saving changes.
Detail on characteristic setup shown below, as well as the variant order on initial display and after saving a variant record.

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 2 months ago #248766

Hi,

Thanks for the additional details. I was able to reproduce the issue consistantly and fix it.
Change the code:

foreach($variant_data as $d) {
					$ppid = (int)$d->variant_product_id;
					if(isset($product->variants[$ppid])) {
						if(empty($product->variants[$ppid]->characteristics))
							$product->variants[$ppid]->characteristics = array();

						$pcid = (int)$product->characteristics[$d->characteristic_parent_id]->characteristic_id;
						$value = new stdClass();
						$value->id = $d->characteristic_id;
						$value->value = $d->characteristic_value;
						$product->variants[$ppid]->characteristics[$pcid] = $value;
					}
				}
to:
if(!empty($product->characteristics)) {
					$i = 0;
					foreach($product->characteristics as &$c) {
						$c->sort_value = $i++;
					}
					unset($c);
				}

				foreach($variant_data as $d) {
					$ppid = (int)$d->variant_product_id;
					if(!isset($product->variants[$ppid]))
						continue;
					
					if(empty($product->variants[$ppid]->characteristics))
						$product->variants[$ppid]->characteristics = array();

					$pcid = (int)$product->characteristics[$d->characteristic_parent_id]->characteristic_id;
					$value = new stdClass();
					$value->id = $d->characteristic_id;
					$value->value = $d->characteristic_value;
					$product->variants[$ppid]->characteristics[$pcid] = $value;
					
					if(!isset($product->variants[$ppid]->sorting_value))
						$product->variants[$ppid]->sorting_value = array();
					$i = (int)$product->characteristics[ (int)$d->characteristic_parent_id ]->sort_value;
					$product->variants[$ppid]->sorting_value[ $i ] = (int)$d->characteristic_ordering;
				}
				usort($product->variants, array(&$this, 'variantSortingCallback'));
in administrator/components/com_hikashop/views/product/view.html.php and that will fix the problem.

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

  • Posts: 113
  • Thank you received: 18
8 years 2 months ago #248795

Perfect, thanks.
This fixes the variants changing order.

I'll revisit pricing issues if I see it again and can document a means to recreate.

The following user(s) said Thank You: nicolas

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

Time to create page: 0.070 seconds
Powered by Kunena Forum