/** * Create the product condition * @param int|string $id * @return string */ protected function _createProductCondition($id) { $table = new Products_Model_DbTable_Product(); $adapter = $table->getAdapter(); $conditions = array(); foreach (array('product_id') as $field) { $conditions[] = $adapter->quoteInto($field . ' = ?', $id); } return implode(' OR ', $conditions); }
/** * Fetch product companies by Agent Quals * @return Products_Model_ProductCompanies */ public function fetchProductCompaniesByAgent($id) { $agentStateList = null; $agentContractList = null; $this->checkAcl('read'); $cache = Zend_Controller_Action_HelperBroker::getStaticHelper('Cache')->getManager()->getCache('database'); $cacheKey = md5('companiesByAgent_' . $id); $agentContractService = Zend_Controller_Action_HelperBroker::getStaticHelper('Service')->direct('agentContract', 'agents'); $agentContracts = $agentContractService->fetchContractsByAgent($id); if (null === $agentContracts) { return null; } foreach ($agentContracts as $key => $value) { $agentContractList .= $agentContracts[$key]['product_company_id'] . ', '; } $table = new Products_Model_DbTable_Product(); $db = $table->getAdapter(); $select = $db->select()->from('product')->joinLeft('product_company', 'product.product_company_id = product_company.product_company_id', array('product_company_name'))->joinLeft('product_category', 'product.product_category_id = product_category.product_category_id', array('product_category_name'))->where('product_id = ?', $id); $companiesByAgent = $db->fetchRow($select); if (null === $companiesByAgent) { return null; } return $companiesByAgent; }