magento,帮助理解默认产品模板代码
我在magento是一个新手,但我正试图在尽可能短的时间内学会它。我正在经历:上面写着: 文件:app/design/frontend/base/default/template/catalog/product/list.phtml包含:magento,帮助理解默认产品模板代码,magento,Magento,我在magento是一个新手,但我正试图在尽可能短的时间内学会它。我正在经历:上面写着: 文件:app/design/frontend/base/default/template/catalog/product/list.phtml包含: <?php $_productCollection=$this->getLoadedProductCollection() ?> <?php if(!$_productCollection->count()): ?>
<?php $_productCollection=$this->getLoadedProductCollection() ?> <?php if(!$_productCollection->count()): ?> <div class="note-msg">
<?php echo $this->__("There are no products matching the selection.") ?> </div>
<?php else: ?>
之后,前面提到的页面写入:块的_getProductCollection然后实例化模型并读取它们的数据,将结果返回给模板
我在这里简直不知所措_getProductCollection()有以下行:
if (is_null($this->_productCollection))
1) _productCollection是否表示受保护的变量$\u productCollection
if (is_null($this->_productCollection)) {
$layer = $this->getLayer();
2) $layer=$this->getLayer()plz的解释是什么
之后我得到:
if ($this->getShowRootCategory()) {
$this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
}
3) 方法getShowRootCategory()在哪里
4) 什么样的方法可以帮助我了解该系列的优缺点:
$this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
5) 对许多人来说,我的问题可能听起来很简单。但是作为magento的初学者,你能参考任何在线资源来学习所有这些东西和其他东西吗
祝你好运如果(为空($This->\u productCollection))是OOP代码常见的一种缓存技术,因为方法在对象上下文中缓存其变量,如果对同一对象或在同一对象内多次调用这些方法,则它会传递缓存的变量,而不是再次从数据库中请求
您可以通过将代码库变灰或从源代码中查找您感兴趣的方法来回答其他问题。有时一个方法是一个神奇的方法(set,get),你在它后面找不到一个方法定义
grep ' getRootCategoryId' app/code/ -rsn
app/code/core/Mage/Core/Model/Store/Group.php:275: public function getRootCategoryId()
app/code/core/Mage/Core/Model/Store.php:850: public function getRootCategoryId()
要使用的最基本的grep模式是:
- 使用
查找方法及其在代码库中的定义位置[space]methodname(
- 使用
查找此方法在代码库中的调用位置>methodname(
- 如果您想知道为什么在您的代码库中没有getSomeVariable()的定义,请使用
来查找魔法方法的设置位置>setMethodName(
是的
2)
Mage\u Catalog\u Block\u Product\u List::getLayer()
返回目录层模型(Mage\u Catalog\u model\u layer
)。它在下面的代码中使用
3) 这是一种神奇的方法,几乎所有magento类都扩展了Varien_对象
类。在此阅读有关Varien_对象的更多信息
4) 对不起,我不明白这个问题是关于什么的
5) 为了避免此类问题,您应该先阅读,并且只有在理解之后才应该阅读(顺便说一句,这些内容有点过时)。#Anton,“…或者从源代码中找到您感兴趣的方法。”我问了第3个问题,就是因为这个原因。@coder,我的grep示例显示了文件、行、,方法或你在这里不理解的部分是什么?
grep ' getRootCategoryId' app/code/ -rsn
app/code/core/Mage/Core/Model/Store/Group.php:275: public function getRootCategoryId()
app/code/core/Mage/Core/Model/Store.php:850: public function getRootCategoryId()