Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Latest (Последние товары)


 Share

Recommended Posts

Доброго всем дня помогите пожалуйста сделать рандом при выводе последних товаров. Плз!

public function getLatestProducts($limit) {
		$product_data = $this->cache->get('product.latest.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit);

		if (!$product_data) { 
			$query = $this->db->query("SELECT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, 
			(SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) 
			AS rating FROM " . DB_PREFIX . 
			"product p LEFT JOIN " . DB_PREFIX . 
			"product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . 
			"product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . 
			"manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . 
			"stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.status = '1'
			 
			AND p.date_available <= NOW() AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'
			AND p.available = 1
			AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' 
			AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "'
			
			ORDER BY p.date_added DESC LIMIT " . (int)$limit);
		 	 
			$product_data = $query->rows;

			$this->cache->set('product.latest.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit, $product_data);
		}
		
		return $product_data;
	}
Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.