I need a discount price in all products in store to -5%. It has to show in product detail page and also product listing page like the individual discount price (strike-through). I want to apply the discount to all products in store globally. As i have tried, we have option to set discount price in the option tab while adding products but adding discount for each product seems to be long process. So i want to apply it globally. Any help or ideas will be greatly appreciated.
I checked some extensions but all show the global discount in the checkout page. I want to show it in the product details page based on the product price.
in product controller
$this->load->model('catalog/product');
$products = $this->model_catalog_product->getProducts();
foreach ($products as $product) {
$this->model_catalog_product->setdiscount($product['product_id'],$product['price']);
}
in model
public function getProducts()
{
$query = $this->db->query("SELECT product_id, price FROM oc_product");
return $query->rows;
}
public function setdiscount($id,$price)
{
$price=($price*95)/100;
$query = $this->db->query("INSERT INTO oc_product_discount (product_id,customer_group_id,quantity,priority,price,date_start,date_end) VALUES ('".$id."','1','1','1','".$price."','xxx','yyy')");
}
xxx and yyy of your choice. and do change the customer_group_id,quantity,priority as per your req.
i have provided you the flow, do changes wherever you want.