public function action_detail() { $request = $this->request->current(); $element_uri = $request->param('element_uri'); $element_id = $request->param('element_id'); $orm = ORM::factory('catalog_Element')->where('id', '=', $element_id)->where('uri', '=', $element_uri)->find(); if (!$orm->loaded()) { throw new HTTP_Exception_404(); } $this->category = $this->_get_category($orm->category_id); $catalog_element = new Catalog_Element(); $properties = $catalog_element->get_properties(array($orm)); $properties = reset($properties); $nomenclature = $this->_get_nomenclature($orm); $images = $this->_get_images($orm); $this->template->set_filename('modules/catalog/detail')->set('orm', $orm)->set('properties', $properties)->set('nomenclature', $nomenclature)->set('images', $images); $this->breadcrumbs[] = array('title' => $orm->title); }
private function parse_basket($basket) { $result = array(); $nom_list = ORM::factory('Nomenclature')->where('id', 'IN', array_keys($basket))->find_all(); $product_list = ORM::factory('catalog_Element')->where('id', 'IN', array_unique($nom_list->as_array(NULL, 'product_id')))->find_all()->as_array('id'); $catalog_element = new Catalog_Element(); $product_props = $catalog_element->get_properties($product_list); $nom_list = $nom_list->as_array('id'); $nomenclature_element = new Nomenclature_Element(); $nom_props = $nomenclature_element->get_properties($nom_list); foreach ($basket as $_key => $_count) { $_orm_nom = Arr::get($nom_list, $_key); if (empty($_orm_nom)) { continue; } $_orm_product = Arr::get($product_list, $_orm_nom->product_id); if (empty($_orm_product)) { continue; } $_props = Arr::get($nom_props, $_orm_nom->id, array()); $result[$_key] = array('product_id' => $_orm_product->id, 'nomenclature_id' => $_orm_nom->id, 'name' => make_nomenclature_name($_orm_product, $_orm_nom), 'count' => (int) $_count, 'price' => Arr::path($_props, 'Price.value'), 'discount' => $this->discount($product_props, $_props)); } return $result; }