大佬教程收集整理的这篇文章主要介绍了为什么 products.php 不会影响 product.twig Opencart 3.0 中的任何更改?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<?php
class ControllerProductProduct extends Controller {
private $error = array();
public function index() {
$this->load->language('product/product');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),'href' => $this->url->link('common/home')
);
$this->load->model('catalog/category');
if (isset($this->request->get['path'])) {
$path = '';
$parts = explode('_',(String)$this->request->get['path']);
$category_ID = (int)array_pop($parts);
foreach ($parts as $path_ID) {
if (!$path) {
$path = $path_ID;
} else {
$path .= '_' . $path_ID;
}
$category_info = $this->model_catalog_category->getcategory($path_ID);
if ($category_info) {
$data['breadcrumbs'][] = array(
'text' => $category_info['name'],'href' => $this->url->link('product/category','path=' . $path)
);
}
}
// Set the last category breadcrumb
$category_info = $this->model_catalog_category->getcategory($category_ID);
if ($category_info) {
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['breadcrumbs'][] = array(
'text' => $category_info['name'],'path=' . $this->request->get['path'] . $url)
);
}
}
$this->load->model('catalog/manufacturer');
if (isset($this->request->get['manufacturer_ID'])) {
$data['breadcrumbs'][] = array(
'text' => $this->language->get('texT_Brand'),'href' => $this->url->link('product/manufacturer')
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_ID']);
if ($manufacturer_info) {
$data['breadcrumbs'][] = array(
'text' => $manufacturer_info['name'],'href' => $this->url->link('product/manufacturer/info','manufacturer_ID=' . $this->request->get['manufacturer_ID'] . $url)
);
}
}
if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
$url = '';
if (isset($this->request->get['search'])) {
$url .= '&search=' . $this->request->get['search'];
}
if (isset($this->request->get['tag'])) {
$url .= '&tag=' . $this->request->get['tag'];
}
if (isset($this->request->get['description'])) {
$url .= '&description=' . $this->request->get['description'];
}
if (isset($this->request->get['category_ID'])) {
$url .= '&category_ID=' . $this->request->get['category_ID'];
}
if (isset($this->request->get['sub_category'])) {
$url .= '&sub_category=' . $this->request->get['sub_category'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_search'),'href' => $this->url->link('product/search',$url)
);
}
if (isset($this->request->get['product_ID'])) {
$product_ID = (int)$this->request->get['product_ID'];
} else {
$product_ID = 0;
}
$this->load->model('catalog/product');
// $product_info = $this->model_catalog_product->getProduct($product_ID);
$product_info = $this->model_catalog_product->getProduct($product_ID);
$query_categorIEs = $this->model_catalog_product->getCategorIEs($product_ID);
$categorIEs = array();
foreach ($query_categorIEs as $cat) {
$ocb_category = $this->model_catalog_category->getcategory($cat['category_ID']);
$category_info['category_ID'] = $ocb_categorY['category_ID'];
$category_info['name'] = $ocb_categorY['name'];
$data['categorIEs'][] = $category_info;
}
if ($product_info) {
$url = '';
if (isset($this->request->get['path'])) {
$url .= '&path=' . $this->request->get['path'];
}
if (isset($this->request->get['filter'])) {
$url .= '&filter=' . $this->request->get['filter'];
}
if (isset($this->request->get['manufacturer_ID'])) {
$url .= '&manufacturer_ID=' . $this->request->get['manufacturer_ID'];
}
if (isset($this->request->get['search'])) {
$url .= '&search=' . $this->request->get['search'];
}
if (isset($this->request->get['tag'])) {
$url .= '&tag=' . $this->request->get['tag'];
}
if (isset($this->request->get['description'])) {
$url .= '&description=' . $this->request->get['description'];
}
if (isset($this->request->get['category_ID'])) {
$url .= '&category_ID=' . $this->request->get['category_ID'];
}
if (isset($this->request->get['sub_category'])) {
$url .= '&sub_category=' . $this->request->get['sub_category'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['breadcrumbs'][] = array(
'text' => $product_info['name'],'href' => $this->url->link('product/product',$url . '&product_ID=' . $this->request->get['product_ID'])
);
$this->document->settitle($product_info['Meta_title']);
$this->document->setDescription($product_info['Meta_description']);
$this->document->setKeywords($product_info['Meta_keyword']);
$this->document->addlink($this->url->link('product/product','product_ID=' . $this->request->get['product_ID']),'canonical');
$this->document->addScript('catalog/vIEw/JavaScript/jquery/magnific/jquery.magnific-popup.min.Js');
$this->document->addStyle('catalog/vIEw/JavaScript/jquery/magnific/magnific-popup.CSS');
$this->document->addScript('catalog/vIEw/JavaScript/jquery/datetiR_727_11845@epicker/moment/moment.min.Js');
$this->document->addScript('catalog/vIEw/JavaScript/jquery/datetiR_727_11845@epicker/moment/moment-with-locales.min.Js');
$this->document->addScript('catalog/vIEw/JavaScript/jquery/datetiR_727_11845@epicker/bootstrap-datetiR_727_11845@epicker.min.Js');
$this->document->addStyle('catalog/vIEw/JavaScript/jquery/datetiR_727_11845@epicker/bootstrap-datetiR_727_11845@epicker.min.CSS');
$data['heading_title'] = $product_info['name'];
$data['text_minimum'] = sprintf($this->language->get('text_minimum'),$product_info['minimum']);
$data['text_login'] = sprintf($this->language->get('text_login'),$this->url->link('account/login','',truE),$this->url->link('account/register',truE));
$this->load->model('catalog/revIEw');
$data['tab_revIEw'] = sprintf($this->language->get('tab_revIEw'),$product_info['revIEws']);
$data['product_ID'] = (int)$this->request->get['product_ID'];
$data['manufacturer'] = $product_info['manufacturer'];
$data['manufacturers'] = $this->url->link('product/manufacturer/info','manufacturer_ID=' . $product_info['manufacturer_ID']);
$data['model'] = $product_info['model'];
$data['reWARD'] = $product_info['reWARD'];
$data['points'] = $product_info['points'];
$data['description'] = HTML_entity_decode($product_info['description'],ENT_QUOTES,'UTF-8');
if ($product_info['quantity'] <= 0) {
$data['stock'] = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$data['stock'] = $product_info['quantity'];
} else {
$data['stock'] = $this->language->get('text_instock');
}
$this->load->model('tool/image');
if ($product_info['image']) {
$data['popup'] = $this->model_tool_image->resize($product_info['image'],$this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_wIDth'),$this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height'));
} else {
$data['popup'] = '';
}
if ($product_info['image']) {
$data['thumb'] = $this->model_tool_image->resize($product_info['image'],$this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_wIDth'),$this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height'));
} else {
$data['thumb'] = '';
}
$data['images'] = array();
$results = $this->model_catalog_product->getProductimages($this->request->get['product_ID']);
foreach ($results as $result) {
$data['images'][] = array(
'popup' => $this->model_tool_image->resize($result['image'],$this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')),'thumb' => $this->model_tool_image->resize($result['image'],$this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_wIDth'),$this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height'))
);
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$data['price'] = $this->currency->format($this->tax->calculate($product_info['price'],$product_info['tax_class_ID'],$this->config->get('config_tax')),$this->session->data['currency']);
} else {
$data['price'] = false;
}
if ((float)$product_info['special']) {
$data['special'] = $this->currency->format($this->tax->calculate($product_info['special'],$this->session->data['currency']);
} else {
$data['special'] = false;
}
if ($this->config->get('config_tax')) {
$data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'],$this->session->data['currency']);
} else {
$data['tax'] = false;
}
$discounts = $this->model_catalog_product->getProductdiscounts($this->request->get['product_ID']);
$data['discounts'] = array();
foreach ($discounts as $discount) {
$data['discounts'][] = array(
'quantity' => $discount['quantity'],'price' => $this->currency->format($this->tax->calculate($discount['price'],$this->session->data['currency'])
);
}
$data['options'] = array();
foreach ($this->model_catalog_product->getProductoptions($this->request->get['product_ID']) as $option) {
$product_option_value_data = array();
foreach ($option['product_option_value'] as $option_value) {
if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) {
if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float)$option_value['price']) {
$price = $this->currency->format($this->tax->calculate($option_value['price'],$this->config->get('config_tax') ? 'P' : falsE),$this->session->data['currency']);
} else {
$price = false;
}
$product_option_value_data[] = array(
'product_option_value_ID' => $option_value['product_option_value_ID'],'option_value_ID' => $option_value['option_value_ID'],'name' => $option_value['name'],'image' => $this->model_tool_image->resize($option_value['image'],50,50),'price' => $price,'price_prefix' => $option_value['price_prefix']
);
}
}
$data['options'][] = array(
'product_option_ID' => $option['product_option_ID'],'product_option_value' => $product_option_value_data,'option_ID' => $option['option_ID'],'name' => $option['name'],'type' => $option['type'],'value' => $option['value'],'required' => $option['required']
);
}
if ($product_info['minimum']) {
$data['minimum'] = $product_info['minimum'];
} else {
$data['minimum'] = 1;
}
$data['revIEw_status'] = $this->config->get('config_revIEw_status');
if ($this->config->get('config_revIEw_guest') || $this->customer->isLogged()) {
$data['revIEw_guest'] = true;
} else {
$data['revIEw_guest'] = false;
}
if ($this->customer->isLogged()) {
$data['CUSTOMER_NAME'] = $this->customer->getFirstname() . ' ' . $this->customer->getLastname();
} else {
$data['CUSTOMER_NAME'] = '';
}
$data['revIEws'] = sprintf($this->language->get('text_revIEws'),(int)$product_info['revIEws']);
$data['raTing'] = (int)$product_info['raTing'];
// Captcha
if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('revIEw',(array)$this->config->get('config_captcha_page'))) {
$data['captcha'] = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha'));
} else {
$data['captcha'] = '';
}
$data['share'] = $this->url->link('product/product','product_ID=' . (int)$this->request->get['product_ID']);
$data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_ID']);
$data['products'] = array();
$results = $this->model_catalog_product->getProductRelated($this->request->get['product_ID']);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'],$this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_wIDth'),$this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_height'));
} else {
$image = $this->model_tool_image->resize('placeholder.png',$this->config->get('theme_' . $this->config->get('config_theme') . '_image_related_height'));
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($result['price'],$result['tax_class_ID'],$this->session->data['currency']);
} else {
$price = false;
}
if ((float)$result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'],$this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'],$this->session->data['currency']);
} else {
$tax = false;
}
if ($this->config->get('config_revIEw_status')) {
$raTing = (int)$result['raTing'];
} else {
$raTing = false;
}
$data['products'][] = array(
'product_ID' => $result['product_ID'],'thumb' => $image,'name' => $result['name'],'description' => utf8_substr(trim(Strip_Tags(HTML_entity_decode($result['description'],'UTF-8'))),$this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..','price' => $price,'special' => $special,'tax' => $tax,'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,'raTing' => $raTing,'href' => $this->url->link('product/product','product_ID=' . $result['product_ID'])
);
}
$data['Tags'] = array();
if ($product_info['tag']) {
$Tags = explode(',',$product_info['tag']);
foreach ($Tags as $tag) {
$data['Tags'][] = array(
'tag' => trim($tag),'tag=' . trim($tag))
);
}
}
$data['recurrings'] = $this->model_catalog_product->getProfiles($this->request->get['product_ID']);
$this->model_catalog_product->updateVIEwed($this->request->get['product_ID']);
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['contenT_Bottom'] = $this->load->controller('common/contenT_Bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setoutput($this->load->vIEw('product/product',$data));
} else {
$url = '';
if (isset($this->request->get['path'])) {
$url .= '&path=' . $this->request->get['path'];
}
if (isset($this->request->get['filter'])) {
$url .= '&filter=' . $this->request->get['filter'];
}
if (isset($this->request->get['manufacturer_ID'])) {
$url .= '&manufacturer_ID=' . $this->request->get['manufacturer_ID'];
}
if (isset($this->request->get['search'])) {
$url .= '&search=' . $this->request->get['search'];
}
if (isset($this->request->get['tag'])) {
$url .= '&tag=' . $this->request->get['tag'];
}
if (isset($this->request->get['description'])) {
$url .= '&description=' . $this->request->get['description'];
}
if (isset($this->request->get['category_ID'])) {
$url .= '&category_ID=' . $this->request->get['category_ID'];
}
if (isset($this->request->get['sub_category'])) {
$url .= '&sub_category=' . $this->request->get['sub_category'];
}
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_error'),$url . '&product_ID=' . $product_ID)
);
$this->document->settitle($this->language->get('text_error'));
$data['conTinue'] = $this->url->link('common/home');
$this->response->addheader($this->request->server['SERVER_PROTOCol'] . ' 404 Not Found');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['contenT_Bottom'] = $this->load->controller('common/contenT_Bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setoutput($this->load->vIEw('error/not_found',$data));
}
}
public function revIEw() {
$this->load->language('product/product');
$this->load->model('catalog/revIEw');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
$data['revIEws'] = array();
$revIEw_@R_705_10586@l = $this->model_catalog_revIEw->get@R_705_10586@lRevIEwsByProductID($this->request->get['product_ID']);
$results = $this->model_catalog_revIEw->getRevIEwsByProductID($this->request->get['product_ID'],($page - 1) * 5,5);
foreach ($results as $result) {
$data['revIEws'][] = array(
'author' => $result['author'],'text' => nl2br($result['text']),'raTing' => (int)$result['raTing'],'date_added' => date($this->language->get('date_format_short'),strtotime($result['date_added']))
);
}
$pagination = new Pagination();
$pagination->@R_705_10586@l = $revIEw_@R_705_10586@l;
$pagination->page = $page;
$pagination->limit = 5;
$pagination->url = $this->url->link('product/product/revIEw','product_ID=' . $this->request->get['product_ID'] . '&page={pagE}');
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'),($revIEw_@R_705_10586@l) ? (($page - 1) * 5) + 1 : 0,((($page - 1) * 5) > ($revIEw_@R_705_10586@l - 5)) ? $revIEw_@R_705_10586@l : ((($page - 1) * 5) + 5),$revIEw_@R_705_10586@l,ceil($revIEw_@R_705_10586@l / 5));
$this->response->setoutput($this->load->vIEw('product/revIEw',$data));
}
public function write() {
$this->load->language('product/product');
$Json = array();
if ($this->request->server['requEST_METHOD'] == 'POST') {
if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 25)) {
$Json['error'] = $this->language->get('error_name');
}
if ((utf8_strlen($this->request->post['text']) < 25) || (utf8_strlen($this->request->post['text']) > 1000)) {
$Json['error'] = $this->language->get('error_text');
}
if (empty($this->request->post['raTing']) || $this->request->post['raTing'] < 0 || $this->request->post['raTing'] > 5) {
$Json['error'] = $this->language->get('error_raTing');
}
// Captcha
if ($this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('revIEw',(array)$this->config->get('config_captcha_page'))) {
$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/valIDate');
if ($captcha) {
$Json['error'] = $captcha;
}
}
if (!isset($Json['error'])) {
$this->load->model('catalog/revIEw');
$this->model_catalog_revIEw->addRevIEw($this->request->get['product_ID'],$this->request->post);
$Json['success'] = $this->language->get('text_success');
}
}
$this->response->addheader('Content-Type: application/Json');
$this->response->setoutput(Json_encode($Json));
}
public function getRecurringDescription() {
$this->load->language('product/product');
$this->load->model('catalog/product');
if (isset($this->request->post['product_ID'])) {
$product_ID = $this->request->post['product_ID'];
} else {
$product_ID = 0;
}
if (isset($this->request->post['recurring_ID'])) {
$recurring_ID = $this->request->post['recurring_ID'];
} else {
$recurring_ID = 0;
}
if (isset($this->request->post['quantity'])) {
$quantity = $this->request->post['quantity'];
} else {
$quantity = 1;
}
$product_info = $this->model_catalog_product->getProduct($product_ID);
$query_categorIEs = $this->model_catalog_product->getCategorIEs($product_ID);
$categorIEs = array();
foreach ($query_categorIEs as $cat) {
$ocb_category = $this->model_catalog_category->getcategory($cat['category_ID']);
$category_info['category_ID'] = $ocb_categorY['category_ID'];
$category_info['name'] = $ocb_categorY['name'];
$data['categorIEs'][] = $category_info;
}
$recurring_info = $this->model_catalog_product->getProfile($product_ID,$recurring_ID);
$Json = array();
if ($product_info && $recurring_info) {
if (!$Json) {
$frequencIEs = array(
'day' => $this->language->get('text_day'),'week' => $this->language->get('text_week'),'semi_month' => $this->language->get('text_semi_month'),'month' => $this->language->get('text_month'),'year' => $this->language->get('text_year'),);
if ($recurring_info['trial_status'] == 1) {
$price = $this->currency->format($this->tax->calculate($recurring_info['trial_price'] * $quantity,$this->session->data['currency']);
$trial_text = sprintf($this->language->get('text_trial_description'),$price,$recurring_info['trial_cycle'],$frequencIEs[$recurring_info['trial_frequency']],$recurring_info['trial_duration']) . ' ';
} else {
$trial_text = '';
}
$price = $this->currency->format($this->tax->calculate($recurring_info['price'] * $quantity,$this->session->data['currency']);
if ($recurring_info['duration']) {
$text = $trial_text . sprintf($this->language->get('text_payment_description'),$recurring_info['cycle'],$frequencIEs[$recurring_info['frequency']],$recurring_info['duration']);
} else {
$text = $trial_text . sprintf($this->language->get('text_payment_cancel'),$recurring_info['duration']);
}
$Json['success'] = $text;
}
}
$this->response->addheader('Content-Type: application/Json');
$this->response->setoutput(Json_encode($Json));
}
}
@H_675_2@这是我的 product.twig 代码:
{% if (categorIEs) %}
{% for category in categorIEs %}
{% if category.category_ID %}
<a>{{Category.namE}}:{{Category.category_ID}}<a><br>
{% endif %}
{% endfor %}
{% endif %}
@H_675_2@帮我做这件事。我试图编辑 product.php 中的代码,但它根本不起作用。主题编辑器没有显示我的主题,所以我在文件中手动编辑代码。
以上是大佬教程为你收集整理的为什么 products.php 不会影响 product.twig Opencart 3.0 中的任何更改?全部内容,希望文章能够帮你解决为什么 products.php 不会影响 product.twig Opencart 3.0 中的任何更改?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。