Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getCategory($id, $all = false) {
- if (!is_numeric($id)) {
- //Определение ID категории...
- }
- if ($all) {
- } else {
- //$field = is_numeric($id)?'data_id':'alias';
- $moduleId = $this->getModuleId();
- $list = $this->getAdapter()
- ->select()
- ->from(array('p' => $this->_name))
- ->where("p.category_id = ?", $id)
- ->joinLeft(array('m'=>'system_meta'), "m.data_id = p.data_id AND m.module_id=$moduleId")
- ->group('p.data_id')
- ->query()->fetchAll();
- //Докрутить постраничку...
- $idsList = array(); //Список ID выбранных продуктов, для дальнейшей обработки
- array_walk($list, create_function('$k, $v, &$idsList', '$idsList[] = $k["data_id"];'), &$idsList);
- $list = array_combine($idsList, $list); //Подготовили массив продуктов для дальнейшей обработки...
- /**
- * Выбираем характеристики...
- */
- $model = new Catalog_Model_Products_Properties;
- $properties = $this->getAdapter()
- ->select()
- ->from(array('pp'=>$model->getTableName()))
- ->where('product_id IN (?)', $idsList)
- ->joinLeft(array('cp'=>'catalog_properties'), 'cp.id=pp.property_id', array('property_title'=>'title', 'type'))
- ->query()->fetchAll();
- //Подготавливаем характеристики...
- $preparedProperties = array();
- foreach($properties as $v) {
- $preparedProperties[$v['product_id']]['properties'][$v['property_id']]['title'] = $v['property_title'];
- $preparedProperties[$v['product_id']]['properties'][$v['property_id']]['type'] = $v['type'];
- $preparedProperties[$v['product_id']]['properties'][$v['property_id']]['values'][] = $v['value'];
- }
- foreach($list as $i=>&$v) {
- $v['properties'] = $preparedProperties[$i]['properties'];
- }
- Zend_Debug::dump($list);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement