/** * @param int $customerId */ public function findProductsCoalesced($customerId) { $productsTable = new Products(); $products = $productsTable->fetchAll(); $productsCoalesced = array(); if ($products->count() > 0) { foreach ($products as $p) { $cp = $this->find($p->product_id, $customerId)->current(); if ($cp) { $productsCoalesced[] = array('product_id' => $cp->product_id, 'sku' => $cp->sku ?: $p->sku, 'name' => $cp->name ?: $p->name, 'description' => $cp->description ?: $p->description, 'unit_price' => $cp->unit_price ?: $p->unit_price); } else { $productsCoalesced[] = array('product_id' => $p->product_id, 'sku' => $p->sku, 'name' => $p->name, 'description' => $p->description, 'unit_price' => $p->unit_price); } } } return $productsCoalesced; }
/** * View a list of all products */ public function indexAction() { $productsTable = new Products(); $this->view->products = $productsTable->fetchAll(); }