Author Topic: Save function in product edit  (Read 529 times)

alexanderflr

  • Beginner
  • *
  • Posts: 38
  • VirtueMart Version: 3.2.2
Save function in product edit
« 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,
VM 3.2.4 on Joomla! 3.8.1 Stable, PHP Version 7.0.25

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1097
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.5
Re: Save function in product edit
« Reply #1 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
Joomla 3.8.1
Virtuemart 3.2.5
Olympiantheme Hera (customized)

alexanderflr

  • Beginner
  • *
  • Posts: 38
  • VirtueMart Version: 3.2.2
Re: Save function in product edit
« Reply #2 on: September 13, 2017, 11:16:47 am »
Hi,
I checked that and is nothing to do with prices  :'(

Thank you.
VM 3.2.4 on Joomla! 3.8.1 Stable, PHP Version 7.0.25

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1097
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.5
Re: Save function in product edit
« Reply #3 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
Joomla 3.8.1
Virtuemart 3.2.5
Olympiantheme Hera (customized)

alexanderflr

  • Beginner
  • *
  • Posts: 38
  • VirtueMart Version: 3.2.2
Re: Save function in product edit
« Reply #4 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  :'(
VM 3.2.4 on Joomla! 3.8.1 Stable, PHP Version 7.0.25

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9372
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Save function in product edit
« Reply #5 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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

alexanderflr

  • Beginner
  • *
  • Posts: 38
  • VirtueMart Version: 3.2.2
Re: Save function in product edit
« Reply #6 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...  :'(
VM 3.2.4 on Joomla! 3.8.1 Stable, PHP Version 7.0.25

JM0308

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Save function in product edit
« Reply #7 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

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2333
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Save function in product edit
« Reply #8 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
Code: [Select]
<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.

JM0308

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Save function in product edit
« Reply #9 on: October 06, 2017, 08:47:37 am »
Thank you for your help I will give it a go and let you know!

alexanderflr

  • Beginner
  • *
  • Posts: 38
  • VirtueMart Version: 3.2.2
Re: Save function in product edit
« Reply #10 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.
VM 3.2.4 on Joomla! 3.8.1 Stable, PHP Version 7.0.25

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2333
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Save function in product edit
« Reply #11 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.

alexanderflr

  • Beginner
  • *
  • Posts: 38
  • VirtueMart Version: 3.2.2
Re: Save function in product edit
« Reply #12 on: October 09, 2017, 17:09:41 pm »
Hi,

Thank you very much, do you know what lines must be modified? Thank you.
VM 3.2.4 on Joomla! 3.8.1 Stable, PHP Version 7.0.25

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2333
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Save function in product edit
« Reply #13 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)

alexanderflr

  • Beginner
  • *
  • Posts: 38
  • VirtueMart Version: 3.2.2
Re: Save function in product edit
« Reply #14 on: October 11, 2017, 10:28:34 am »
Thank you very much, you are a star!
Works great, exactly what I needed.
VM 3.2.4 on Joomla! 3.8.1 Stable, PHP Version 7.0.25