这个问题是通用的,我只想知道如何将对象转储到日志文件.为了澄清事情,我正在通过一个例子进行阐述.
我已成功使用magento观察者在某些事件发生时调用方法.举个例子,我观察通过以下方式保存货件的时间:
<sales_order_shipment_save_after>
Run Code Online (Sandbox Code Playgroud)
我成功地调用了一种方法.我想抓住货物,然后将对象转储到日志文件中.例如.
public function newShipment(Varien_Event_Observer $observer)
{
$shipment = $observer->getEvent()->getShipment();
$shipId = $shipment->getId();
Mage::log("shipment ({$shipId}) created/saved", null, 'shipments.log');
//trying to dump $shipment data into the log file
Mage::log("({var_dump($shipment)}) ------", null, 'shipments.log');
Mage::log("----------------------------", null, 'shipments.log');
}
Run Code Online (Sandbox Code Playgroud)
货件ID被打印到日志文件中就好了,但显然它不会按照我想要的方式转储对象,因为我写的代码是错误的.
任何人都可以告诉我如何将对象转储到日志文件中,并且可能会给我一些关于日志记录的建议吗?
非常感谢.
我已经设法使用下面的代码片段在浏览器中打开一个 pdf。而不是在同一页面中打开,我希望它在新的浏览器选项卡中打开。
我没有使用标签。这段代码调用了许多操作,最后它应该显示 pdf。它工作正常,但我希望它在新选项卡中打开。
这可能吗?如果可以,请向我解释如何操作。
我在 php 5.3 上使用 Magento (EE 12.02) 应用程序。
$file = $pdf_file_path;
$filename = $file_name;
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
@readfile($file);
Run Code Online (Sandbox Code Playgroud) 构建自定义adminhtml模块.我用一个简单的表格.它看起来像这样:
<?php
class Namespace_Modulename_Block_Adminhtml_Modulename_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('modulename_form',array('legend'=>Mage::helper('modulename')->__('Module Data')));
$fieldset->addField('test', 'text', array(
'label' => Mage::helper('modulename')->__('Test'),
'name' => 'test',
));
// I want to add a custom button here. Say an action called "Add Option".
//Clicking this action adds input boxes or dropdowns to the form that are to
//to be included in the post when submitting the form (obviously).
Run Code Online (Sandbox Code Playgroud)
我一直在寻找Stack溢出的解决方案,但却找不到可能有用的东西.然后我尝试在Mage Core中搜索类似的东西.
在管理面板中,如果我转到[目录 - >属性 - >管理属性]并单击标准属性,例如"制造商",在第二个选项卡上,名为"管理标签/选项",我会看到以下屏幕:
有一个按钮和动作,允许我向表单添加选项(以文本框的形式).将此识别为我想要复制的东西,我进入核心试图弄清楚要做什么.如果我打开以下文件(Magento Enteprise …
在Magento 1.9成功注册后,我想将所有客户重定向到自定义页面.
我尝试了很多东西.首先,我成功地覆盖了核心客户帐户控制器.
我试图自定义以下操作:
尝试设置重定向网址或设置BeforeAuthUrl
//$successUrl = $this->_getUrl('*/*/index', array('_secure' => true));
$successUrl = $this->_getUrl('*/*/success');
$this->_getSession()->setBeforeAuthUrl('http://test.local/customer/account/success/');
if ($this->_getSession()->getBeforeAuthUrl()) {
$successUrl = $this->_getSession()->getBeforeAuthUrl(true);
}
return $successUrl;
Run Code Online (Sandbox Code Playgroud)
请注意,此时$ successUrl在此处返回时是正确的.我看到有一些后期调度方法,我假设这些方法会破坏这个网址并始终返回到客户/帐户/索引.
我已经阅读了几个关于这个主题的帖子,但找不到解决这个问题的明确答案.
我甚至设置了隐藏的表单元素'success_url',试图按照其他地方提供的步骤作为解决方案.
为了能够显示一次性注册成功页面,需要遵循的完整,正确的流程是什么?
我目前正试图简单地将一个块添加到自定义Adminhtml模块.我能够显示块的内容,但它在页面顶部呈现灰色背景,然后标准的magento布局与设计和菜单直接呈现在它下面.
我试图以正确的方式做事情,以学习最佳实践,并遵循书籍和教程以及magento核心,但到目前为止一直无法正确添加内容.
到目前为止我有:
public function indexAction()
{
$this->loadLayout();
$this->_setTitle();
$main_block = new Invent_General_Block_Info();
echo $main_block->toHtml();
//$this->_addContent($main_block);
$this->renderLayout();
Run Code Online (Sandbox Code Playgroud)
我可以看到在Mage Core中这样做的一般方法就像是
/**
* Append customers block to content
*/
$this->_addContent(
$this->getLayout()->createBlock('adminhtml/customer', 'customer')
);
Run Code Online (Sandbox Code Playgroud)
因为我已经创建了块$ main_block,所以对我来说没有意义 - > createBlock,所以我不知道该怎么做.
任何协助都像往常一样受到赞赏 谢谢!