Работаю с MVC на opencart. Сделал функцию для вывода ид с бд в файле модели public function GetIdProd($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category"); $cat_id = mysql_fetch_array($query); return $cat_id; } в файле control сделал: $productCategoryId = $this->model_catalog_product->GetIdProd($product_id); во вью echo $productCategoryId; и мне пишет ошибку Fatal error: Call to undefined function GetIdProd() in /var/www/u0190288/data/www/1es1.ru/vqmod/vqcache/vq2-catalog_controller_product_product.php on line 14
Вообще по сообщению не похоже, что он работает как с методом объекта. Что в $this->model_catalog_product?
Что мне нужно сделать достать id категории. Вот этим вот методом пытаюсь его достать. ДА работаю с этим в первые. --- Добавлено --- Как его узнать?
Пардон муа, уважаемый, но за каким хером лезть в дебри, если не знаешь основ? var_dump($this->model_catalog_product); в строке перед вызывающей ошибку.
object(ModelCatalogProduct)#405 (1) { ["registry"rotected]=> object(Registry)#368 (1) { ["data":"Registry"rivate]=> array(24) { ["load"]=> object(Loader)#369 (1) { ["registry":"Loader"rivate]=> *RECURSION* } ["config"]=> object(Config)#370 (1) { ["data":"Config"rivate]=> array(233) { ["config_store_id"]=> int(0) ["sub_total_sort_order"]=> string(1) "1" ["sub_total_status"]=> string(1) "1" ["total_sort_order"]=> string(1) "9" ["total_status"]=> string(1) "1" ["shipping_sort_order"]=> string(1) "3" ["shipping_status"]=> string(1) "1" ["shipping_estimator"]=> string(1) "1" ["category_status"]=> string(1) "1" ["account_status"]=> string(1) "1" ["affiliate_status"]=> string(1) "1" ["category2_status"]=> string(1) "1" ["search_suggestion_status"]=> string(1) "1" ["search_suggestion_module"]=> array(1) { [0]=> array(1) { ["search_suggestion"]=> int(1) } } ["search_suggestion_options"]=> array(9) { ["key"]=> string(0) "" ["search_order"]=> string(4) "name" ["search_order_dir"]=> string(3) "asc" ["search_logic"]=> string(3) "and" ["search_limit"]=> int(7) ["search_cache"]=> int(1) ["search_css"]=> string(628) ".ui-autocomplete .ui-menu-item, .ui-autocomplete .ui-menu-item div, .ui-autocomplete .ui-menu-item span { margin: 0; padding: 0 3px; border: 0; text-align:left; overflow: hidden; } .ui-autocomplete .ui-menu-item span { margin-right: 5px; } .ui-autocomplete .ui-menu-item .label { font-weight: bold; color: black; } .ui-autocomplete .image img { border: 1px solid #E7E7E7; } .ui-autocomplete .price-old { margin-right: 2px; color: #F00; text-decoration: line-through; } .ui-autocomplete .price-new { font-weight: bold; } .ui-autocomplete { z-index: 99 !important; }" ["search_where"]=> array(1) { ["name"]=> int(1) } ["search_field"]=> array(15) { ["name"]=> array(4) { ["sort"]=> int(0) ["show"]=> int(1) ["location"]=> string(7) "newline" ["css"]=> string(74) "color: #38B0E3; font-weight: bold; text-decoration: none; height: 20px;" } ["price"]=> array(4) { ["sort"]=> int(1) ["show"]=> int(1) ["show_field_name"]=> int(0) ["location"]=> string(7) "newline" } ["image"]=> array(1) { ["sort"]=> int(2) } ["manufacturer"]=> array(1) { ["sort"]=> int(3) } ["model"]=> array(1) { ["sort"]=> int(4) } ["sku"]=> array(1) { ["sort"]=> int(5) } ["upc"]=> array(1) { ["sort"]=> int(6) } ["ean"]=> array(1) { ["sort"]=> int(7) } ["jan"]=> array(1) { ["sort"]=> int(8) } ["isbn"]=> array(1) { ["sort"]=> int(9) } ["mpn"]=> array(1) { ["sort"]=> int(10) } ["quantity"]=> array(1) { ["sort"]=> int(11) } ["description"]=> array(1) { ["sort"]=> int(12) } ["attributes"]=> array(1) { ["sort"]=> int(13) } ["rating"]=> array(1) { ["sort"]=> int(14) } } } ["cod_total"]=> string(4) "0.01" ["cod_order_status_id"]=> string(1) "1" ["cod_geo_zone_id"]=> string(1) "0" ["cod_status"]=> string(1) "1" ["cod_sort_order"]=> string(1) "1" ["simple_settings"]=> string(21374) "{"address":{"geoIpMode":1,"rows":{"default":[{"displayWhen":{},"hideForGuest":false,"hideForLogged":false,"id":"firstname","masterField":"","requireWhen":{},"required":"1","sortOrder":1,"type":"field","$$hashKey":"194"},{"displayWhen":{},"hideForGuest":false,"hideForLogged":false,"id":"postcode","masterField":"","requireWhen":{},"required":"1","sortOrder":2,"type":"field","$$hashKey":"199"},{"displayWhen":{},"hideForGuest":false,"hideForLogged":false,"id":"city","masterField":"","requireWhen":{},"required":"1","sortOrder":3,"type":"field","$$hashKey":"198"},{"displayWhen":{},"hideForGuest":false,"hideForLogged":false,"id":"address_1","masterField":"","requireWhen": Ну и тд
Хм... Объект... Но ошибка-то тогда другая должна быть. Ладно, давай вот на что посмотрим: var_dump(get_class_methods($this->model_catalog_product));
array(22) { [0]=> string(12) "updateViewed" [1]=> string(15) "getIdCategories" [2]=> string(10) "getProduct" [3]=> string(11) "getProducts" [4]=> string(18) "getProductSpecials" [5]=> string(17) "getLatestProducts" [6]=> string(18) "getPopularProducts" [7]=> string(21) "getBestSellerProducts" [8]=> string(20) "getProductAttributes" [9]=> string(17) "getProductOptions" [10]=> string(19) "getProductDiscounts" [11]=> string(16) "getProductImages" [12]=> string(17) "getProductRelated" [13]=> string(18) "getProductLayoutId" [14]=> string(13) "getCategories" [15]=> string(16) "getTotalProducts" [16]=> string(11) "getProfiles" [17]=> string(10) "getProfile" [18]=> string(23) "getTotalProductSpecials" [19]=> string(11) "__construct" [20]=> string(5) "__get" [21]=> string(5) "__set" } Fatal error: Call to undefined function getIdCategories() in /var/www/u0190288/data/www/1es1.ru/vqmod/vqcache/vq2-catalog_controller_product_product.php on line 170
Не, @Ganzal, ты просто Open Cart не знаешь. Там есть плагин VQMod, который на основе xml-файлов подменяет файлы opencart своими, для того, чтобы плагины погли изменять стандартное поведение без необходимости перезаписывать файлы. Сделано кривовато, но движок уже долго держится. Надо сбросить кеш именно VQMod. ТС, попробуй удалить файлы из /var/www/u0190288/data/www/1es1.ru/vqmod/vqcache --- Добавлено --- Кстати, которая ветка OC? 1.х или 2.х? --- Добавлено --- Кстати, @Dron-Boy, резервную копию сделай. Я не знаю, насколько ты изменил файлы, сможет ли VQMod свои правила правильно применить.
О, там ещё OCMod есть.... Не помню сейчас, где его кеш. Ну попробуй сначала VQMod-а кешу сбросить --- Добавлено --- Всё что там есть, чтоб VQMod перегенерил. Только скачай куда-нибудь предварительно
Fatal error: Call to undefined function getIdCategories() in /var/www/u0190288/data/www/1es1.ru/vqmod/vqcache/vq2-catalog_controller_product_product.php on line 169
О, название поменялось. А где должна была быть функция getIdCategories ? Отлаживай, думай мозгом. Надеюсь, догадался, как VQMod называет файлы? Вообще, штука препротивная, не люблю его. Но без него большая часть плагинов не работает --- Добавлено --- Посмотри ещё папку с правилами VQMod, может какие-то правила заставляют его твой код затирать. --- Добавлено --- Как называется, не помню. Там куча XML-файлов лежать должно
я создаю ее в моделе (функцию) в контролере ее вызываю. И во вью пытаюсь вывести. --- Добавлено --- Я вобще это правильно пишу? public function GetIdProd($product_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category"); $cat_id = mysql_fetch_array($query); return $cat_id; } в файле control сделал: $productCategoryId = $this->model_catalog_product->GetIdProd($product_id); во вью echo $productCategoryId;