php - Select category by id on the admin product page -


is possible define category id on admin product page?

the idea capture category id (previously registered) , not name. found these codes change responsible function:

admin/model/catalog/product.php

public function getproductcategories($product_id) {   $product_category_data = array();    $query = $this->db->query("select * " . db_prefix . "product_to_category product_id = '" . (int)$product_id . "'");    foreach ($query->rows $result) {      $product_category_data[] = $result['category_id'];   }    return $product_category_data; 

}

admin/controller/catalog/product.php

// categories   $this->load->model('catalog/category');    if (isset($this->request->post['product_category'])) {      $categories = $this->request->post['category_id'];   } elseif (isset($this->request->get['product_id'])) {            $categories = $this->model_catalog_product->getproductcategories($this->request->get['product_id']);   } else {      $categories = array();   }    $this->data['product_categories'] = array();    foreach ($categories $category_id) {      $category_info = $this->model_catalog_category->getcategory($category_id);       if ($category_info) {         $this->data['product_categories'][] = array(            'category_id' => $category_info['category_id'],            'name'        => ($category_info['path'] ? $category_info['path'] . ' > ' : '') . $category_info['name']         );      }   } 

admin/view/template/catalog/product_form.tpl

<tr>           <td><?php echo $entry_category; ?></td>           <td><input type="text" name="category" value="" /></td>         </tr>         <tr>           <td>&nbsp;</td>           <td><div id="product-category" class="scrollbox">               <?php $class = 'odd'; ?>               <?php foreach ($product_categories $product_category) { ?>               <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>               <div id="product-category<?php echo $product_category['category_id']; ?>" class="<?php echo $class; ?>"><?php echo $product_category['name']; ?><img src="view/image/delete.png" alt="" />                 <input type="hidden" name="product_category[]" value="<?php echo $product_category['category_id']; ?>" />               </div>               <?php } ?>             </div></td>         </tr> 

the problem not in php , don't know change results. thank or idea!

if (!empty($data['filter_name'])) { $sql .= " , cp.category_id '" . $this->db->escape($data['filter_name']) . "%'";

line 211 in admin/model/catalog/category.php

i found solution question, doesn't solved problem. thank me!


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -