VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: alexanderflr on September 12, 2017, 17:45:30 PM

Title: Save function in product edit
Post by: alexanderflr on September 12, 2017, 17:45:30 PM
Hi,

Does anyone know where I can find Save classes for product price?
I'm looking for a way to stop Save button to save prices when I edit a product. I don't need the possibility to edit the prices because I created a software that does that and inserts the prices automatically in the database.

I'm using Joomla! 3.7.5 Stable, PHP 7.0.18, Virtuemart 3.2.2
Thank you,
Title: Re: Save function in product edit
Post by: Jörgen on September 12, 2017, 22:45:11 PM
Make an override for the view:

administrator/templates/isis/html/com_virtuemart/product/product_edit_status.php

regards

Jörgen @ Kreativ Fotografi
Title: Re: Save function in product edit
Post by: alexanderflr on September 13, 2017, 11:16:47 AM
Hi,
I checked that and is nothing to do with prices  :'(

Thank you.
Title: Re: Save function in product edit
Post by: Jörgen on September 13, 2017, 11:30:27 AM
Sorry
Was a bit Quick, You will find the original files under
administrator/components/com_virtuemart/views/product/tmpl

and the override should be this file
administrator/templates/youradmintemplate/html/com_virtuemart/product/product_edit_price.php

regards

Jörgen @ Kreativ Fotografi
Title: Re: Save function in product edit
Post by: alexanderflr on September 20, 2017, 09:58:53 AM
Hi,

Thank you.

I tried to do that but if I change something else to the product and save, all of the prices disappear  :'(
Title: Re: Save function in product edit
Post by: Milbo on September 22, 2017, 10:36:00 AM
Because the normal way in php is to load the form with the current values and to store the whole thing.

So when your system sets the prices, they should be there, when you edit the product and stored with the rest of the form. There is only one function working different, the toggle function. we update only the boolean, when you use the toggle function in the list (to publish or make a product featured). In all other cases, the form overwrites anything which is there. The same with the config. When you store the config, it starts with fresh data. It loads first the config file, then the all values get overwritten by the form. So any values stored in the config, which are not in the file or form get deleted.
Title: Re: Save function in product edit
Post by: alexanderflr on October 05, 2017, 15:07:47 PM
Hi Milbo,

I understand what you are saying and makes sense but must be a way not to load them, will help me also not the have them at all in the product edit page...  :'(
Title: Re: Save function in product edit
Post by: JM0308 on October 05, 2017, 17:59:38 PM
Hi

I have been trying to do this on a website I am working on 2, we do not have as may prices as the original poster but we still have around 70/80 shopper groups and the load time is slow when editing each product.

What I have been trying to do is stop the "Product Pricing" section of the "Product Information Tab" from loading on open. I cant find the correct file that builds the product edit page? I can delete the code from the Product Edit page and it stops the pricing from loading but then when I save it deletes all the data. So my plan was to take out the product pricing from loading so when it saves the product pricing isn't there to save so it just does nothing!

Any ideas?

Thanks
Jack
Title: Re: Save function in product edit
Post by: Studio 42 on October 06, 2017, 02:33:49 AM
YOu have a simple solution.
Hide the price container in ROOT/administrator/components/com_virtuemart/views/product/tmpl/product_edit_information.php
search : Product pricing
and replace <fieldset> (it's the second in the file) with
<fieldset style="display:none'>

If you need to quick modify products, you can Buy VM Be Pro and disable price column too in this component.
Title: Re: Save function in product edit
Post by: JM0308 on October 06, 2017, 08:47:37 AM
Thank you for your help I will give it a go and let you know!
Title: Re: Save function in product edit
Post by: alexanderflr on October 09, 2017, 14:00:08 PM
Hi Studio 24,

I done this before but the pricing is still loading even if is not visible. I have around 150 price groups, the loading time is not the best.
Title: Re: Save function in product edit
Post by: Studio 42 on October 09, 2017, 15:51:11 PM
Problem is that VM does update all fields on save. So removing the field, remove the price.
If you really want remove it, then you have to modify the product model, so price is never saved.
Title: Re: Save function in product edit
Post by: alexanderflr on October 09, 2017, 17:09:41 PM
Hi,

Thank you very much, do you know what lines must be modified? Thank you.
Title: Re: Save function in product edit
Post by: Studio 42 on October 09, 2017, 18:01:36 PM
search in
public function store (

add
$data['mprices'] = null;
before
if (isset($data['mprices']['product_price']) and count($data['mprices']['product_price']) > 0){

add
$old_price_ids = null;
before
if (!empty($old_price_ids) and count($old_price_ids) ) {

should work (or comment all the codes about prices in this function)
Title: Re: Save function in product edit
Post by: alexanderflr on October 11, 2017, 10:28:34 AM
Thank you very much, you are a star!
Works great, exactly what I needed.