简体   繁体   English

了解Magento标签块类型=“ catalog / product_list” name =“ home.catalog.product.list”

[英]Understanding Magento tag block type=“catalog/product_list” name=“home.catalog.product.list”

The code I mean is : 我的意思是:

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}

Do you have a link where I can learn about it? 您是否有一个链接可以从中了解到? I want to know if there another attribute. 我想知道是否还有另一个属性。 I'm trying to show products based on category, is it possible with kind of this code? 我试图显示基于类别的产品,这种代码是否可以?

The code snippet that your referencing here is a widget that using in magento. 您在此处引用的代码段是在magento中使用的小部件。

What is widget ? 什么是小部件?

If you are familiar with wordpress widgets, you may have an idea about what is widgets. 如果您熟悉Wordpress窗口小部件,则可能对什么是窗口小部件有所了解。 According to me, Widgets are mainly designed for non-technial people who works with magento. 据我说,小部件主要是为与magento合作的非技术人员设计的。 By simply putting widgets, they can do some awesome works in magento. 通过简单地放置小部件,他们可以在magento中完成一些很棒的工作。 Magento has some default widgets availble with it and if you need you can develop widgets. Magento有一些默认的小部件可用,如果需要,您可以开发小部件。 Its just like a frontend extension development. 就像前端扩展开发一样。

Theory For Widget that in Question 有问题的小部件理论

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}

This is our widget. 这是我们的小部件。 As it's name suggest, it is a product list widget that is used to show some list of products in frontend. 顾名思义,它是一个产品列表小部件,用于在前端显示一些产品列表。 Wait a second... Then what is this code do then ? 等一下...那么这段代码是做什么的呢?

<block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml" />

Now this is not a widget. 现在这不是小部件。 This is a block which will use in Magento layouts to include product list based on some condition. 这是一个块,将在Magento布局中使用,以根据某些条件包括产品列表。 That some condition will vary according to our need. 某些条件会根据我们的需要而有所不同。 Mean when it appears inside a category layout section, it will use to show products that are belong to a particular category. 意味着当它出现在类别布局部分中时,它将用于显示属于特定类别的产品。 Now suppose, if you need to show some products based on some other conditions, then there too you need to use this block to list those products. 现在假设,如果您需要根据其他条件显示某些产品,那么您也需要使用此框列出这些产品。 The main thing you need to understand here is, you may need to do a lot of thing in order to to make this block show "something" in frontend. 您在这里需要了解的主要事情是,您可能需要做很多事情才能使此块在前端显示“某些内容”。

But in case of widgets, we can skip this, by simply putting this code inside CMS->Pages . 但是,如果是小部件,我们可以跳过此过程,只需将代码放在CMS->Pages Magento will automatically render that block widget for you. Magento将自动为您渲染该块小部件。 So simple huh ? 这么简单吧? That is the power of widgets :) 那就是小部件的力​​量:)

What is this widget actually ? 这个小部件到底是什么? : This is infact a block that will use to show product list in frontend. :实际上这是一个块,将用于在前端显示产品列表。 Since it is a widget, it has some additional power than a normal block . 由于它是一个小部件,因此它具有比普通block更高的功能 One of that additional power is, widgets are automatically rendering one, while block may or may not be get automatically rendered. 附加功能之一是,小部件会自动渲染一个,而block可能会或可能不会自动渲染。 The above block and widget represents the block Mage_Catalog_Product_List . 上面的块和小部件代表块Mage_Catalog_Product_List To trace the class that represent by this widget is pretty simple. 跟踪此小部件代表的类非常简单。 It is based on the type that we specified. 它基于我们指定的类型。 Here the type is catalog/product_list . 这里的类型是catalog/product_list catalog stands for Magento cor module Mage_Catalog and product_list is path to our block, this will turns to Block_Product_List . catalog代表Magento cor模块Mage_Catalogproduct_list是我们块的路径,它将变为Block_Product_List So when add on we get Mage_Catalog_Product_List . 因此,当添加时,我们得到Mage_Catalog_Product_List Now this block is used to show product lists in Magento. 现在,该块用于在Magento中显示产品列表。 Each blocks in Magento do different kind of jobs. Magento中的每个块都执行不同的工作。

Hope that makes sense. 希望有道理。 For more details on widget Go To This Link 有关小部件的更多详细信息,请转到此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM