Magento >后端>新菜单项需要特定操作 ->我该怎么做?
我在后端创建了一个新菜单,并添加了一些子菜单。其中名为“管理页面”的子项之一必须检索与以“CMS_”开头的属性集对应的所有产品,并且不应包含价格列。
到目前为止我已经这样做了:
app/code/community/Mycompany/Content/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Content>
<version>0.1.0</version>
</Mycompany_Content>
</modules>
<adminhtml>
<menu>
<newmenu translate="title">
<title>Content</title>
<sort_order>31</sort_order>
<action>adminhtml/newmenu/</action>
<children>
<newchildmenu translate="title">
<title>Manage Pages</title>
<action>adminhtml/newmenu/</action>
</newchildmenu>
<newchildmenu1 translate="title">
<title>Manage Attributes</title>
<action>adminhtml/catalog_product_attribute</action>
</newchildmenu1>
<newchildmenu2 translate="title">
<title>Manage Categories</title>
<action>adminhtml/catalog_category/</action>
</newchildmenu2>
</children>
</newmenu>
</menu>
</adminhtml>
</config>
app/etc/modules/Mycompany_Content.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Content>
<active>true</active>
<codePool>community</codePool>
</Mycompany_Content>
</modules>
</config>
再一次,这是我想要什么: - 当我按“管理页面”时,我希望被发送到按特定属性集过滤的“管理产品”页面 - 名称以“CMS_”开头且没有价格列的属性集。
我该怎么做?
提前致谢! HT
好吧,也许我可以尝试剖析这个问题。
如何在后端创建根据特定属性集过滤的“管理产品”页面的副本?
I have created a new menu in my backend, and added some children. One of these children named "Manage Pages" must retrieve all the products that correspond to the attribute sets that begin with "CMS_" and should not have a price column.
I have done this so far:
app/code/community/Mycompany/Content/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Content>
<version>0.1.0</version>
</Mycompany_Content>
</modules>
<adminhtml>
<menu>
<newmenu translate="title">
<title>Content</title>
<sort_order>31</sort_order>
<action>adminhtml/newmenu/</action>
<children>
<newchildmenu translate="title">
<title>Manage Pages</title>
<action>adminhtml/newmenu/</action>
</newchildmenu>
<newchildmenu1 translate="title">
<title>Manage Attributes</title>
<action>adminhtml/catalog_product_attribute</action>
</newchildmenu1>
<newchildmenu2 translate="title">
<title>Manage Categories</title>
<action>adminhtml/catalog_category/</action>
</newchildmenu2>
</children>
</newmenu>
</menu>
</adminhtml>
</config>
app/etc/modules/Mycompany_Content.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Content>
<active>true</active>
<codePool>community</codePool>
</Mycompany_Content>
</modules>
</config>
Once again, this is what I want:
- when I press “Manage Pages”, I want to be sent to a “Manage Products” page filtered on a certain set of atrributes - sets of attributes that have names begining with “CMS_”, and without the price column.
How do I do that?
Thanks in advance!
HT
Ok, maybe I can try dissecting the problem.
How do I create a copy of "Manage Products" page in the backend which is filtered on a certain attribute set?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如艾伦正确指出的那样,该网站并不是为任何人做任何工作,但如果您愿意帮助自己,那么社区可以提供线索。为此,这里有一个学习该做什么的通用方法。
首先查看现有的管理产品,URL 显示以“/admin/catalog_product/index/”开头的路径。 URL 使用 route/controller /action 格式,因此我们可以推断负责的类为
Mage_Adminhtml_Catalog_ProductController
,方法为indexAction
。(“admin”路由到“Adminhtml”,“catalog_product”成为“Catalog”文件夹和“ProductController”文件)
方法
indexAction
包含对loadLayout() 和
renderLayout()
这是正在使用布局文件的明确标志。我们的下一个线索在“app/design/adminhtml/default/layout/catalog.xml”中。catalog.xml 的第一部分是
,幸运的是它与之前的路径匹配。在它的“内容”中,它创建了一个类型为“adminhtml/catalog_product”的块,这解析为Mage_Adminhtml_Block_Catalog_Product
。经检查,它有一个
_prepareLayout()
方法,与所有块一样,它在页面输出之前被调用。此方法添加一个“添加产品”按钮和“adminhtml/catalog_product_grid”中的一个块。从页面中可以看到,该网格与 admin 中的所有其他网格的形式相同。
Mage_Adminhtml_Block_Catalog_Product_Grid
类扩展了Mage_Adminhtml_Block_Widget_Grid
,它完成了创建网格的所有艰苦工作。只需要进行一些小的更改即可使其工作。这里重要的方法是
_prepareCollection()
和_prepareColumns()
。还有_prepareMassaction()
定义了网格右上角显示的操作下拉框。几乎所有管理页面的工作方式都与此相同。要自己制作,您需要:
Mage_Adminhtml_Block_Widget_Grid
来创建您自己的块。_prepareColumns()
和_prepareCollection()
方法,您将在其中根据您的要求进行数据库访问和过滤结果。另一个相关指南可以在此处找到。事实上,查看 Magento wiki 和 知识库 了解更多信息。以上并不是完整的说明,之后还有很多东西需要学习。
As Alan rightly points out this site isn't here to do anyone's work for them but if you are willing to help yourself then the community can provide clues. To that end here is a general method to learn what to do.
Start with looking at the existing Manage Products, the URL shows the path begins with "/admin/catalog_product/index/". URLs use a route/controller/action format so we can deduce that the class responsible will be
Mage_Adminhtml_Catalog_ProductController
and the method isindexAction
.("admin" routes to "Adminhtml", "catalog_product" becomes the "Catalog" folder and "ProductController" file)
The method
indexAction
contains calls toloadLayout()
andrenderLayout()
which is a sure sign that a layout file is being used. Our next clue is in "app/design/adminhtml/default/layout/catalog.xml".The first section of catalog.xml is
<adminhtml_catalog_product_index>
which luckily matches the path from before. In it's "content" it creates a block with type "adminhtml/catalog_product", this resolves toMage_Adminhtml_Block_Catalog_Product
.On inspection it has a
_prepareLayout()
method, as with all blocks it is called before the page is output. This method adds an "Add Product" button and a block from "adminhtml/catalog_product_grid".You can see from looking at the page that the grid is of the same form as all other grids in admin. The class
Mage_Adminhtml_Block_Catalog_Product_Grid
extendsMage_Adminhtml_Block_Widget_Grid
which does all the hard work to make a grid. Only some small changes are needed to make it work.The significant methods here are
_prepareCollection()
and_prepareColumns()
. There is also_prepareMassaction()
which defines the actions drop-down box that show in the top right of grids.Nearly all admin pages work in the same way as this. To make your own you will need to;
Mage_Adminhtml_Block_Widget_Grid
to make your own block._prepareColumns()
and a_prepareCollection()
method which is where you will do the database access and filter the results as per your requirements.Another relevant guide can be found here. In fact, look through the Magento wiki and knowledgebase for more information. The above is not a complete set of instructions and there is still much to learn thereafter.