Jump to content

PrestaShopDatabaseException Unknown column 'sa.id_product' in 'field list'


Recommended Posts

Hi everyone, This is the error I've been getting when I click on "Details" for a product in Stock Coverage. This is for products that have multiple combinations set, and in a multi-store setting. Any help will be appreciated. - Joel

 

 

[PrestaShopDatabaseException]

Unknown column 'sa.id_product' in 'field list'
 

			SELECT SQL_CALC_FOUND_ROWS			 a.*			, a.id_product_attribute as id, a.id_product, stock_view.reference, stock_view.ean13,							stock_view.upc, stock_view.usable_quantity as stock			FROM `ps_product_attribute` a						 INNER JOIN						  (						  	SELECT SUM(s.usable_quantity) as usable_quantity, s.id_product_attribute, s.reference, s.ean13, s.upc						   	FROM ps_stock s						   	WHERE s.id_product = 14						   	GROUP BY s.id_product_attribute						   )						   stock_view ON (stock_view.id_product_attribute = a.id_product_attribute) 						WHERE 1 AND a.id_product = 14 AND a.id_product IN (						SELECT sa.id_product						FROM `ps_product_attribute_shop` sa						WHERE sa.id_shop IN (3, 2, 1, 5, 4)					) 									ORDER BY a.`id_product` ASC LIMIT 0,50
at line 635 in file classes/db/Db.php
629. 			WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);630. 		}631. 		else if (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS'))632. 		{633. 			if ($sql)634. 				throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>');635. 			throw new PrestaShopDatabaseException($this->getMsgError());636. 		}637. 	}638. 639. 	/**
  • DbCore->displayError - [line 325 - classes/db/Db.php] - [1 Arguments]
    319. 		if ($sql instanceof DbQuery)320. 			$sql = $sql->build();321. 322. 		$this->result = $this->_query($sql);323. 		if (_PS_DEBUG_SQL_)324. 			$this->displayError($sql);325. 		return $this->result;326. 	}327. 328. 	/**329. 	 * Execute an INSERT query
  • DbCore->query - [line 501 - classes/db/Db.php] - [1 Arguments]
    Argument [0]			SELECT SQL_CALC_FOUND_ROWS			 a.*			, a.id_product_attribute as id, a.id_product, stock_view.reference, stock_view.ean13,							stock_view.upc, stock_view.usable_quantity as stock			FROM `ps_product_attribute` a						 INNER JOIN						  (						  	SELECT SUM(s.usable_quantity) as usable_quantity, s.id_product_attribute, s.reference, s.ean13, s.upc						   	FROM ps_stock s						   	WHERE s.id_product = 14						   	GROUP BY s.id_product_attribute						   )						   stock_view ON (stock_view.id_product_attribute = a.id_product_attribute) 						WHERE 1 AND a.id_product = 14 AND a.id_product IN (						SELECT sa.id_product						FROM `ps_product_attribute_shop` sa						WHERE sa.id_shop IN (3, 2, 1, 5, 4)					) 									ORDER BY a.`id_product` ASC LIMIT 0,50
  • DbCore->executeS - [line 2820 - classes/controller/AdminController.php] - [3 Arguments]
    2814. 			'.$having_clause.'2815. 			ORDER BY '.((str_replace('`', '', $order_by) == $this->identifier) ? 'a.' : '').$order_by.' '.pSQL($order_way).2816. 			($this->_tmpTableFilter ? ') tmpTable WHERE 1'.$this->_tmpTableFilter : '').2817. 			(($use_limit === true) ? ' LIMIT '.(int)$start.','.(int)$limit : '');2818. 2819. 			$this->_list = Db::getInstance()->executeS($this->_listsql, true, false);2820. 2821. 			if ($this->_list === false)2822. 			{2823. 				$this->_list_error = Db::getInstance()->getMsgError();2824. 				break;
  • AdminControllerCore->getList - [line 210 - controllers/admin/AdminStockCoverController.php] - [6 Arguments]
    204. 	 * AdminController::getList() override205. 	 * @see AdminController::getList()206. 	 */207. 	public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)208. 	{209. 		parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);210. 211. 		if ($this->display == 'details')212. 		{213. 			$nb_items = count($this->_list);214. 
  • AdminStockCoverControllerCore->getList - [line 2016 - classes/controller/AdminController.php] - [1 Arguments]
    2010. 	 */2011. 	public function renderList()2012. 	{2013. 		if (!($this->fields_list && is_array($this->fields_list)))2014. 			return false;2015. 		$this->getList($this->context->language->id);2016. 2017. 		// If list has 'active' field, we automatically create bulk action2018. 		if (isset($this->fields_list) && is_array($this->fields_list) && array_key_exists('active', $this->fields_list)2019. 			&& !empty($this->fields_list['active']))2020. 		{
  • AdminControllerCore->renderList - [line 153 - controllers/admin/AdminStockCoverController.php]
    147. 						   	GROUP BY s.id_product_attribute148. 						   )149. 						   stock_view ON (stock_view.id_product_attribute = a.id_product_attribute)';150. 			$this->_where = 'AND a.id_product = '.$id_product;151. 			$this->_groupBy = 'a.id_product_attribute';152. 			return parent::renderList();153. 		}154. 	}155. 156. 	/**157. 	 * AdminController::renderList() override
  • AdminStockCoverControllerCore->renderDetails - [line 1786 - classes/controller/AdminController.php]
    1780. 				$this->loadObject(true);1781. 			$this->content .= $this->renderView();1782. 		}1783. 		elseif ($this->display == 'details')1784. 		{1785. 			$this->content .= $this->renderDetails();1786. 		}1787. 		elseif (!$this->ajax)1788. 		{1789. 			$this->content .= $this->renderModulesList();1790. 			$this->content .= $this->renderKpis();
  • AdminControllerCore->initContent - [line 380 - controllers/admin/AdminStockCoverController.php]
    374. 		if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))375. 		{376. 			$this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate advanced stock management before using this feature.');377. 			return false;378. 		}379. 		parent::initContent();380. 	}381. 	382. 	public function initProcess()383. 	{384. 		if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
  • AdminStockCoverControllerCore->initContent - [line 180 - classes/controller/Controller.php]
    174. 175. 			if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))176. 				$this->initHeader();177. 178. 			if ($this->viewAccess())179. 				$this->initContent();180. 			else181. 				$this->errors[] = Tools::displayError('Access denied.');182. 183. 			if (!$this->content_only && ($this->display_footer || (isset($this->className) && $this->className)))184. 				$this->initFooter();
  • ControllerCore->run - [line 373 - classes/Dispatcher.php]
    367. 			// Execute hook dispatcher368. 			if (isset($params_hook_action_dispatcher))369. 				Hook::exec('actionDispatcher', $params_hook_action_dispatcher);370. 371. 			// Running controller372. 			$controller->run();373. 		}374. 		catch (PrestaShopException $e)375. 		{376. 			$e->displayMessage();377. 		}
  • DispatcherCore->dispatch - [line 54 - admin/index.php]
    48. 	$_POST['controller'] = strtolower($_POST['tab']);49. if (!isset($_REQUEST['controller']) && isset($_REQUEST['tab']))50. 	$_REQUEST['controller'] = strtolower($_REQUEST['tab']);51. 52. // Prepare and trigger admin dispatcher53. Dispatcher::getInstance()->dispatch();
Edited by europablue (see edit history)
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
×
×
  • Create New...