News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Product ordering in category [input#order] VM2.0.27

Started by AH, February 13, 2014, 20:49:44 PM

Previous topic - Next topic

AH

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.


<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:-


<?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.10.11
php 8.0

AH

#1
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!!

<?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



<?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.10.11
php 8.0

Milbo

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

Milbo

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

QuoteBut 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.10.11
php 8.0

AH

Regards
A

Joomla 3.10.11
php 8.0