Magento >后端>新菜单项需要特定操作 ->我该怎么做?

发布于 2024-09-28 08:53:55 字数 2156 浏览 2 评论 0原文

我在后端创建了一个新菜单,并添加了一些子菜单。其中名为“管理页面”的子项之一必须检索与以“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑脸一如从前 2024-10-05 08:53:55

正如艾伦正确指出的那样,该网站并不是为任何人做任何工作,但如果您愿意帮助自己,那么社区可以提供线索。为此,这里有一个学习该做什么的通用方法。

  • 首先查看现有的管理产品,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() 定义了网格右上角显示的操作下拉框。

几乎所有管理页面的工作方式都与此相同。要自己制作,您需要:

  1. 为您的模块注册一个控制器。以下是关于重载控制器的指南。
  2. 为您的控制器提供渲染布局的操作。
  3. 在“app/design/adminhtml/default/layout”目录中创建一个布局文件,并将其注册到“config.xml”中,以便尊重它。它必须有一个与您的路线、控制器和操作相匹配的部分。
  4. 添加一个块来显示网格小部件。该示例以编程方式创建此内容,但也可以在布局文件中完成。
  5. 扩展Mage_Adminhtml_Block_Widget_Grid来创建您自己的块。
  6. 添加 _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 is indexAction.
    ("admin" routes to "Adminhtml", "catalog_product" becomes the "Catalog" folder and "ProductController" file)

  • The method indexAction contains calls to loadLayout() and renderLayout() 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 to Mage_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 extends Mage_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;

  1. Register a controller for your module. Here is a guide on overloading controllers.
  2. Give your controller an action to render the layout.
  3. Create a layout file in the "app/design/adminhtml/default/layout" directory and register it in your "config.xml" so that it is respected. It must have a section that matches your route, controller and action.
  4. Add a block to display a grid widget. The example creates this programmatically but it can also be done in the layout file.
  5. Extend Mage_Adminhtml_Block_Widget_Grid to make your own block.
  6. Add a _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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文