/** * Fetch product * @param int|string $id * @return Products_Model_Product|null */ public function fetchProductById($id) { $this->checkAcl('read'); $cache = Zend_Controller_Action_HelperBroker::getStaticHelper('Cache')->getManager()->getCache('database'); $cacheKey = md5('productWithCompBy_' . $id); if (!($product = $cache->load($cacheKey))) { $table = new Products_Model_DbTable_Product(); $select = $table->select(); $select->where($this->_createProductCondition($id)); $row = $table->fetchRow($select); if (null === $row) { return null; } $productCompany = $row->findParentRow(new Products_Model_DbTable_ProductCompany()); $row = $row->toArray(); $productCompany = $productCompany->toArray(); unset($productCompany['product_company_deleted']); unset($productCompany['product_company_datetime']); //Merge arrays to add company name to product data $result = array_merge($row, $productCompany); $product = new Products_Model_Product($result); $cache->save($product, $cacheKey, array('products')); } return $product; }