尝试在 Magento 中创建基于规则的静态块
因此,我的一位客户请求在其主页上执行基于规则的静态块。该页面基本上会根据浏览该网站的人的感知性别将几个静态块替换为其他块。它将从用户当前所在的会话或与用户帐户关联的数据中获取此数据。基本上,如果用户在一组特定类别(男士或女士类别)中进行搜索,则应该交换主页上的静态块,这样当用户再次访问该网站时,他们将获得更加个性化的体验。如果用户是该网站的新用户,则会有一组默认的块。
像这样的东西(请原谅我破旧的 php):
if($categories = $user->getViewedCategories()){
foreach($categories as $category){
switch($category){
case 14: //insert womens category id here
echo $staticBlockWomen
break;
case 16: //insert mens category id here
echo $staticBlockMen
break;
}
}
} else {
echo $staticBlockDefault
}
我知道 Magento 跟踪用户通过网站的路径,并且我知道 Magento 中的其他元素可以具有基于此数据的规则(动态横幅和结帐规则),但我真的迷失了从哪里开始。
如果有人能指出我正确的方向,任何帮助将不胜感激!
干杯, 马修
So one of my clients has a request to do rule based static blocks on their home page. The page will basically swap out several static blocks for others based on the perceived gender of the person viewing the site. It will get this data from the session that the user is currently in, or the data associated with the users account. Basically, if a user searches in a specific set of categories (Men's or Women's categories) it should swap the static blocks out on the home page, so when that user visits the site again they will have a more personalized experience. There will be a default set of blocks if the user is new to the site.
Something like this (and excuse my shabby php):
if($categories = $user->getViewedCategories()){
foreach($categories as $category){
switch($category){
case 14: //insert womens category id here
echo $staticBlockWomen
break;
case 16: //insert mens category id here
echo $staticBlockMen
break;
}
}
} else {
echo $staticBlockDefault
}
I know Magento tracks a users path through a site, and I know that other elements in Magento can have rules based on this data (the dynamic banners and checkout rules), but I am really lost on where to get started.
If someone could point me in the right direction, any help would be appreciated!
Cheers,
Matthew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您了解 Magento 的基础知识(至少了解如何创建新块以及如何使用 xml 管理布局)。
如果您需要更多相关信息,
您可以通过几个步骤完成您需要的操作:
1 - 创建您需要的块(在相应的 .phtml 文件中创建一个新模块并在其中创建块类)
2 - 从管理面板,选择要添加块的类别并导航到“自定义设计”选项卡,然后在“自定义布局更新”文本区域中添加如下内容:
这样,每次客户查看所选类别时,都会添加一个块类型的“mymodule/myblock”将添加到内容区域中。
I'm assuming you know the basics of Magento (at least how to create new blocks and how to manage the layout using xml).
If you need more info about that,
You can accomplish what you need in a few steps:
1 - create the blocks you need (create a new module and block classes inside it within the corresponding .phtml files)
2 - from the admin panel, select the category for which you want to add a block and navigate to "Custom Design" tab, then add in the "Custom Layout Update" textarea something like this:
This way, every time the selected category is viewed by the custmer, a block of type "mymodule/myblock" will be added in the content area.