0
我正在尝试学习opencart结构,并尝试在表product
下创建一个新列。新列是“测试”来自新列的回溯值
然后我尝试index.php?route=checkout/cart
此页面下检索数据(与测试替换列价格)
catalog\controller\checkout\cart.php
...
$this->data['products'][] = array(
'key' => $product['key'],
'thumb' => $image,
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''),
'price' => $product['test'], //<-- new column
'total' => $total,
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']),
'remove' => $this->url->link('checkout/cart', 'remove=' . $product['key'])
);
的问题是我没有得到任何输出,和我”我不知道如何使用模型。哪个查询/功能与此页面相关?
问题在于'cart.php'控制器上可用的'$ products'从它们被存储在先前设置的结构中的会话中检索,所以没有'test'索引。参见'/ system/library/cart.php'和方法'getProducts()'来理解我在说什么。如果你想在'catalog/controller/product/category.php'或'catalog/controller/product/product.php'控制器上使用它,你正在尝试的代码**将会工作。如果您在所有产品清单和产品细节中更换价格,购物车内的最终价格就是您的“测试”价值。 – shadyyx 2013-04-10 13:23:47
@shadyyx是它在category.php和product.php下工作,不幸的是没有与控制器\ checkout \ cart.php ... – rusly 2013-04-10 13:36:21
@shadyyx感谢您的信息,我现在看到/system/library/cart.php下的代码我明白它是如何工作的..现在我可以显示我的自定义字段下cart.php ..再次感谢:) – rusly 2013-04-10 13:39:06