Post by Studio10Graphics » Wed Aug 11, 2010 8:18 am

Hi guys,
When adding new products to my store, I notice that the Related Products box is empty. None of my products are showing up there anymore. This happened after I installed the Global Attributes mod for 1.4.7.

Here is my getProductRelated function:

Code: Select all

public function getProductRelated($product_id) {
		$product_data = array();

		$product_related_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
		
		foreach ($product_related_query->rows as $result) { 
			$product_query = $this->db->query("SELECT DISTINCT *, 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.product_id = '" . (int)$result['related_id'] . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.date_available <= NOW() AND p.status = '1'");
			
			if ($product_query->num_rows) {
				$product_data[$result['related_id']] = $product_query->row;
			}
		}
		
		return $product_data;
	}
Any help you can offer is greatly appreciated.


Posts

Joined
Fri Aug 06, 2010 11:36 pm

Post by Studio10Graphics » Wed Aug 11, 2010 8:30 am

Wow. I checked my error logs and I have about a thousand of these:

Code: Select all

2010-08-11 0:16:24 - PHP Notice:  Undefined index:  mode in /home/content/s/t/u/studio10/html/store/admin/controller/catalog/product.php on line 1012
This is the function it's referring to:

Code: Select all

	public function category() {
		$this->load->model('catalog/product');
		
		if (isset($this->request->get['category_id'])) {
			$category_id = $this->request->get['category_id'];
		} else {
			$category_id = 0;
		}
		
		$product_data = array();
		
		$results = $this->model_catalog_product->getProductsByCategoryId($category_id);
		
		foreach ($results as $result) {
			$product_data[] = array(
				'product_id' => $result['product_id'],
				'name'       => $result['name'],
                'mode'       => $result['mode']
			);
		}
		
		$this->load->library('json');
		
		$this->response->setOutput(Json::encode($product_data));
	}
And line 1012 is:

Code: Select all

'mode'       => $result['mode']


Posts

Joined
Fri Aug 06, 2010 11:36 pm

Post by Studio10Graphics » Wed Aug 11, 2010 8:36 am

Problem solved. There was a typo in the functions. "Mode" should have been "model".

Um, thanks for your help? :D


Posts

Joined
Fri Aug 06, 2010 11:36 pm

Post by JAY6390 » Wed Aug 11, 2010 8:59 am

Yeah pretty sure I fixed the same error for someone a while back :)

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom
Who is online

Users browsing this forum: DoctorDredd and 39 guests