Currently, we are adding the total number of pvs.id to the product.price as shown below.
Below is
+1 for Product.price when pvs.id total is 10,
+2 for Product.price when pvs.id total is 20,
+3 for Product.price when pvs.id total is 30,
...
+10 for Product.price when pvs.id totals 100,
I'd like to add it one by one, but is it possible to write it in SQL?
Also, if possible, what kind of code would it be?
Model/Product.php
public$virtualFields=array(
'product_price' = >'
Product.price+(10*(SELECT COALESCE(COUNT(pvs.id), 0) FROM pvs WHERE product_id=Product.id))
)',
);
public$virtualFields=array(
'product_price' = >'
Product.price+(SELECT COALESCE(COUNT(pvs.id), 0) FROM pvs WHERE product_id=Product.id)/10)
)',
);
resolved in .
© 2024 OneMinuteCode. All rights reserved.