Php 在OpenCart中,如何自定义产品页面上可见的信息
好的,首先我想说我不是一个极客程序员。我是编程中级。我最近通过teamtreehouse学习Php,我还没有完成。但我开始用OpenCart制作一个在线商店。我看了一些youtube视频,添加了一些产品、类别等。现在我被折磨得睡不着觉,因为网络上没有合适的解释。问题是——在产品页面上,我有许多产品的奖励积分类别。但在分类页面上唯一可见的是图像、价格、简短描述、添加到购物车选项。很抱歉,如果我不能正确解释…下面是截图的url- 看看我想做什么- 有没有一种方法可以通过opencart的管理页面来实现??如果没有,请指导我如何将其工作的代码。我对php也是新手,但它会让我明白。请帮帮我 有没有办法通过opencart的管理页面来实现这一点??Php 在OpenCart中,如何自定义产品页面上可见的信息,php,admin,categories,opencart2.x,Php,Admin,Categories,Opencart2.x,好的,首先我想说我不是一个极客程序员。我是编程中级。我最近通过teamtreehouse学习Php,我还没有完成。但我开始用OpenCart制作一个在线商店。我看了一些youtube视频,添加了一些产品、类别等。现在我被折磨得睡不着觉,因为网络上没有合适的解释。问题是——在产品页面上,我有许多产品的奖励积分类别。但在分类页面上唯一可见的是图像、价格、简短描述、添加到购物车选项。很抱歉,如果我不能正确解释…下面是截图的url- 看看我想做什么- 有没有一种方法可以通过opencart的管理页面
没有 如果没有,请通过代码指导我如何工作
这是一项非常简单的任务,但如果您不了解web开发的基础知识,您将无法完成它
- 首先,您应该了解MVC设计模式,互联网上有很多非常酷的PHP MVC示例,GIYF李>
- 第二,你应该阅读这篇伟大的文章,它解释了OC的基本原理
- 真正的工作:
- 确保要在类别页面中显示的产品数组中的每个产品都具有奖励点数的值(或您想要的任何数据),您可以通过打开
并转储变量ControllerProductCategory class@catalog/controller/product/category.php
来检查这一点,如果有,那么实际工作中的第1步就完成了,如果没有,您将需要更改$data['products']
ModelCatalogProduct class@catalog/model/catalog/product.php中的模型函数
getProducts()
- 现在,在类别模板文件
中,访问奖励点数的值并将其显示在产品html div中,您将发现它包含在这个循环中catalog/view/theme/your theme文件夹/template/product/category.tpl
foreach($products as$product){
- 确保要在类别页面中显示的产品数组中的每个产品都具有奖励点数的值(或您想要的任何数据),您可以通过打开
这对你来说似乎太难学了(MVC和所有的东西…),但是你必须爬上梯子,祝你好运!在默认的OpenCart代码中尝试类似的东西 第一步 打开文件:
catalog\language\english\product\category.php
查找:
$_['text_price'] = 'Price:';
$_['text_reward'] = 'Reward Points:';
'points' => $result['points'],
$data['text_price'] = $this->language->get('text_price');
$data['text_reward'] = $this->language->get('text_reward');
<p><?php echo $text_reward; ?> <?php echo $product['points']; ?></p>
在以下内容之后添加:
$_['text_price'] = 'Price:';
$_['text_reward'] = 'Reward Points:';
'points' => $result['points'],
$data['text_price'] = $this->language->get('text_price');
$data['text_reward'] = $this->language->get('text_reward');
<p><?php echo $text_reward; ?> <?php echo $product['points']; ?></p>
步骤2 打开文件:
catalog\controller\product\category.php
查找:
'price' => $price,
在以下内容之后添加:
$_['text_price'] = 'Price:';
$_['text_reward'] = 'Reward Points:';
'points' => $result['points'],
$data['text_price'] = $this->language->get('text_price');
$data['text_reward'] = $this->language->get('text_reward');
<p><?php echo $text_reward; ?> <?php echo $product['points']; ?></p>
步骤3 在同一个文件中:
catalog\controller\product\category.php
查找:
$_['text_price'] = 'Price:';
$_['text_reward'] = 'Reward Points:';
'points' => $result['points'],
$data['text_price'] = $this->language->get('text_price');
$data['text_reward'] = $this->language->get('text_reward');
<p><?php echo $text_reward; ?> <?php echo $product['points']; ?></p>
在以下内容之后添加:
$_['text_price'] = 'Price:';
$_['text_reward'] = 'Reward Points:';
'points' => $result['points'],
$data['text_price'] = $this->language->get('text_price');
$data['text_reward'] = $this->language->get('text_reward');
<p><?php echo $text_reward; ?> <?php echo $product['points']; ?></p>
步骤4 打开文件:
catalog\view\theme\default\template\product\category.tpl
查找:
在以下内容之后添加:
$_['text_price'] = 'Price:';
$_['text_reward'] = 'Reward Points:';
'points' => $result['points'],
$data['text_price'] = $this->language->get('text_price');
$data['text_reward'] = $this->language->get('text_reward');
<p><?php echo $text_reward; ?> <?php echo $product['points']; ?></p>
然后检查。我认为这不是我们在stackoverflow中提供帮助的方式!谢谢@Abdo Adel澄清我的问题。你详细的回答确实帮助了我,现在我知道了我的未来。终于明白了。。