Magento 自定义模块。 重定向到另一个模块并返回结账
Magento 购物车是基于 PHP 的 Zend Framework 构建的。 这是我第一次处理 Zend 框架,我遇到了以下困难...
我正在创建一个自定义模块,允许用户在购买产品时上传图像。
每当用户尝试将产品添加到购物车时,我都可以重载 addAction() 方法。 我还可以创建一个自定义模块,向用户呈现表单并接受文件。 但是,我不确定如何将运行模块的代码插入到我的重载方法中:
<?php
require_once 'Mage/Checkout/controllers/CartController.php';
class Company_SpecialCheckout_Checkout_CartController extends Mage_Checkout_CartController
{
# Overloaded addAction
public function addAction()
{
# when user tries to add to cart, request images from them
# *********
# *** what do i do in here to display a custom block ???? ###
# *** and allow addAction to continue only if successfully validated form input ###
# *********
parent::addAction();
}
}
我怀疑我的困难来自于我对 Zend MVC 的处理方式缺乏了解。 我从上到下研究了所有 Magento 文档/wiki/论坛主题。
Magento shopping cart is built on the Zend Framework in PHP. This is the first time I've dealt with the Zend framework and I'm having the following difficulty...
I'm creating a custom module that will allow users to upload images whenever they purchase products.
I can overload the addAction() method whenever a user attempts to add a product to their cart. I can also create a custom module which presents the form to the user and accepts the file(s). However I'm not sure how to insert the code to run my module into my overloaded method:
<?php
require_once 'Mage/Checkout/controllers/CartController.php';
class Company_SpecialCheckout_Checkout_CartController extends Mage_Checkout_CartController
{
# Overloaded addAction
public function addAction()
{
# when user tries to add to cart, request images from them
# *********
# *** what do i do in here to display a custom block ???? ###
# *** and allow addAction to continue only if successfully validated form input ###
# *********
parent::addAction();
}
}
I suspect my difficulties come from my lack of knowledge of the Zend MVC way of doing things. I've studied all the Magento documentation/wikis/forum threads from top to bottom.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我想我会转向一个新的答案,因为我认为我已经设法让它发挥作用。
这是我
创建以下文件的方法;
app/code/local/Company/SpecialCheckout/controllers/Checkout/CartController.php
app/code/local/Company/SpecialCheckout/etc/config.xml
app/etc/modules/Company_SpecialCheckout.xml
首先是控制器,与您完全相同有;
然后是模块配置
,最后是 app/etc/modules 中的配置文件,以确保模块被选中。
然后当你去/checkout/cart 时你应该看到“test”。 这是基于我在此处找到的详细信息。
确保您在 Magento 管理中禁用了配置文件的缓存。
I thought I'd move to a new answer as I think I've managed to get it working.
Here's what I did
created the following files;
app/code/local/Company/SpecialCheckout/controllers/Checkout/CartController.php
app/code/local/Company/SpecialCheckout/etc/config.xml
app/etc/modules/Company_SpecialCheckout.xml
First the controller, which is exactly as you had;
Then the module configuration
and then finally the config file in app/etc/modules to make sure the module is picked up.
then when you go /checkout/cart you should see 'test'. This is based on details I found here.
Make sure you have the cacheing of config files disabled in the Magento admin.
嘿,这个选项是在较新版本的 magento 1.3.1 中提供的,用于从前端上传文件
享受
hey this option is given in newer version of magento 1.3.1 to upload the file from frontend
enjoy
我必须先承认我没有 Magento 的生产经验,但我花了一些时间研究他们的代码。
块结构是在 XML 中定义的,因此您可能不需要实际扩展购物车控制器。
布局 XML 文件可以在 app/design/frontend/default/default/layout 中找到(默认安装)。 在这里您将找到 checkout.xml,它设置结账页面的块结构。
I must admit upfront that I don't have production experience of Magento, but I have spent some time poking around their code.
The block structure is defined in XML, and so you may not need to actually extend the Cart Controller.
The Layout XML files can be found (on a default install) at app/design/frontend/default/default/layout. In here you will find checkout.xml which sets up the block structure for the checkout page.
对于那些坚持这一点的人,我编写了最简单的方法来解决这个问题,而不会使控制器过载。 我的变体基于单页结帐 看看 magento wiki< /a>
For those who stuck on this i wrote the simplest way to solve this problem without overloading controllers. My variant based on onepage checkout take a look in magento wiki
这对我来说是一场噩梦,我在博客中创建了一个教程:
CONTROLLER / OVERRIDE / Frontend
[...]
#^/客户/帐户/#
/我的客户/帐户/
[...]
看一下这个! 如何声明和覆盖magento控制器
It was beeing a nightmare for me, I created a Tutorial in my blog:
CONTROLLER / OVERRIDE / Frontend
[...]
#^/customer/account/#
/mycustomer/account/
[...]
Check this out! How to magento declare and override controllers