Author Topic: Product ordering in category [input#order] VM2.0.27  (Read 1031 times)

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3506
  • VirtueMart Version: 3.8.9
Product ordering in category [input#order] VM2.0.27
« on: February 13, 2014, 20:49:44 pm »
The loss of category product ordering sequence appears to be happening in 2.0.27 when a product is edited.

I see the hidden field in the edit, but it gets set to a different value.

Code: [Select]
<input type="hidden" value="13" name="ordering">

I can see no real benefit of saving the ordering field in product edit.

Assuming that a product can exist in one or more categories and the ordering within these categories will probably be different, I cannot see how saving it on edit can actually work.

A possible option is only save the ordering in the category view, where the new drag and drop works so well!!!!

The ordering is easy to see for all the items in the category and can be adjusted and saved as required.

I recommend that the

administrator/components/com_virtuemart/views/product/tmpl/product_edit_information.php

Is changed to the code below:-

Code: [Select]
<?php
// It is important to have all product information in the form, since we do not preload the parent
// I place the ordering here, maybe we make it editable later.
if(!isset($this->product->ordering)) { 
                            
$this->product->ordering 0;
                            echo 
"<input type='hidden' value="$this->product->ordering ."name='ordering'>";
                        }                     
?>




Just removed this hidden input field if the ordering field has been set thus allowing 0 to be set for new product.

It now works for me and ensures that my ordering in single AND multiple categories is maintained on edit.

Any thoughts?
Regards
A

Joomla 3.9.27
php 7.4

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3506
  • VirtueMart Version: 3.8.9
Re: Product ordering in category [input#order] VM2.0.27
« Reply #1 on: February 23, 2014, 19:17:06 pm »
Looks like this edit failed to make  2.5.0   :'(

administrator/components/com_virtuemart/views/product/tmpl/product_edit_information.php


Editing a product destroys the category ordering that has been saved!!

Code: [Select]
<?php
// It is important to have all product information in the form, since we do not preload the parent
// I place the ordering here, maybe we make it editable later.
if(!isset($this->product->ordering)) $this->product->ordering 0;
?>

<input type="hidden" value="<?php echo $this->product->ordering ?>" name="ordering">
?>


Replace with


Code: [Select]
<?php
// It is important to have all product information in the form, since we do not preload the parent
// I place the ordering here, maybe we make it editable later.
            // stop overwriting the category ordering on product edit!!
            
if(!isset($this->product->ordering)) {
            
$this->product->ordering 0;
            echo 
"<input type='hidden' value="$this->product->ordering ."name='ordering'>";
            }



Regards
A

Joomla 3.9.27
php 7.4

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10152
  • VM3.9 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Product ordering in category [input#order] VM2.0.27
« Reply #2 on: February 23, 2014, 22:50:39 pm »
I wanted to write, did you not read the notice.

But you say it works for you, so I double checked. There are so many orderings in this form, ordering of childs, of media, of customfields....

The normal table is not preloading. But the product_categories table is a VmTableXarray, which actually checks if there is an entry already and does an update. At begin we had the problem that the ordering was always lost, because it the input field was not there. Lets see what the others say, when I add your fix.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3506
  • VirtueMart Version: 3.8.9
Re: Product ordering in category [input#order] VM2.0.27
« Reply #3 on: February 24, 2014, 11:45:32 am »
Milbo

Thanks for the reply, I did not see your notice.

Quote
But the product_categories table is a VmTableXarray, which actually checks if there is an entry already and does an update. At begin we had the problem that the ordering was always lost, because it the input field was not there.

Tested again (as I know you are more often than not correct!) and as you say the field is loaded with the value from the first category/xref entry that is found and does in fact write this entry back correctly. 

The product/category ordering is not destroyed.

However:-

Some products will, of course, reside in multiple directories so having this value in the form and re-writing the single entry back does not produce any additional functionality so the suggested code I have provided still holds true.

The ordering is not editable unless all the xref entries are returned as category/ordering pairs


My ordering was getting messed up as I had a mod to my VmTableXarray so that on migration, the product/category ordering was ported.
Regards
A

Joomla 3.9.27
php 7.4

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3506
  • VirtueMart Version: 3.8.9
Re: Product ordering in category [input#order] VM2.0.27
« Reply #4 on: February 26, 2014, 22:08:59 pm »
Great, it made it to 2.5.1  8)
Regards
A

Joomla 3.9.27
php 7.4