如何将"已启用","无"设置为管理员中"状态","税级"字段的默认值?
我正在开发Magento 1.6中的自定义SMS模块.
我已设置system.xml文件来管理相关的自定义配置字段.
菜单条目显示,但是当我单击它时,将显示404错误页面而不是预期的配置字段列表.
你能看到我的代码中有任何错误吗?
<config>
<tabs>
<mynew_tab translate="label">
<label>SMS Gateway Integration</label>
<sort_order>100</sort_order>
</mynew_tab>
</tabs>
<sections>
<smsconfig translate="label">
<label>SMS Gateway Integration</label>
<sort_order>200</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<tab>mynew_tab</tab>
<groups>
<sms_group translate="label">
<label>My Custom Configurations</label>
<comment>This is example of custom configuration.</comment>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<sms_enabled translate="label tooltip comment">
<label>Is Enabled</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Enable this module.</comment>
</sms_enabled>
<sms_username translate="label tooltip comment">
<label>Sender Email</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Username of the SMS gateway.</comment>
</sms_username>
<sms_password translate="label …Run Code Online (Sandbox Code Playgroud) 我只是使用模块创建器设置了一个带有网格视图的管理模块,它工作得很好,但现在我需要在同一个模块中添加另一个网格视图.
我复制并重命名了与网格视图相关的所有文件(控制器和块文件,但不是模型,因为它们不需要我正在做的事情),并将新创建的块添加到句柄下的布局xml中.新控制器.
使用Firephp,我已经知道所有内容都可以很好地用于我的新视图,直到Grid.php没有加载,并且结束输出只是一个空白页面.
据我所知,这个新视图与模块在名称之外的所有方面生成的原始工作网格视图相同,那么是什么原因导致它无法识别或加载Grid.php?
Mage/Adminhtml/Widget/Grid/Column/Renderer/Concat.php - 有人可以提供一个使用示例吗?例如,它可以用来代替:
$this->addColumn('order_item', array(
'header'=> $this->__('Order # (Item #)'),
'sortable'=> true,
'index'=> 'order_item',
'filter_index'=> "CONCAT(orders.increment_id, ' (', main_table.item_id, ')')",
'width'=> '140px',
));
Run Code Online (Sandbox Code Playgroud) 我正在开发一个"for fun"项目,我希望将其作为一个"有趣"的开源项目发布.我已经建立了一个Arduino网络连接订单通知器,我正在建立Magento adminhtml接口方面.对于我正在做的事情,这可能看起来过于复杂,但是这有其他对我有用的应用程序,我正在尝试学习新的东西.
话虽如此,我在Magento后端的"Reports"旁边创建了一个新的"Arduino"adminhtml菜单项.有些时候Arduino的特定反馈可能会自动禁用模块,在这种情况下,我的目标是从页面中删除菜单项,除非有其他子菜单项,在这种情况下我只删除模块特定的菜单项.同样,对于这个项目来说,这似乎不太现实,但是为了尽可能"正确"做到这一点,这是我的目标,让其他人可以添加"Arduino"菜单项的可能性开放.
现在,我有这个工作伟大,没有问题,如果关闭IF缓存.这是另一种说法,"这不起作用,因为显然每个人都会打开缓存." 也就是说,这是我开始使用的代码:
/**
* Used to disable the Arduino menu option dynamically.
*
* @param Varient_Event_Observer $observer
*/
public function controllerActionLayoutGenerateBlocksBefore(Varien_Event_Observer $observer)
{
//We only want to disable the arduino menu if our module was specifically disabled in backend
if(Mage::helper('mynamespace_myarduinomodule')->isDisabled())
{
/* @var $arduinoItems Varien_Simplexml_Element */
/* @var $parent Varien_Simplexml_Element */
$arduinoItems = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu/arduinomenu/children');
$parent = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu');
//If there are other menu options in the arduino menu option we only want to hide
//the menu items …Run Code Online (Sandbox Code Playgroud) 曾几何时我尝试创建一些自定义列.我创建了像我应该拥有的整个XML结构.我创建了控制器.我甚至创建了自定义网格控制器.
创建自定义网格后,我认为列将排序.我错了,错了.单击列标题不执行任何操作.
建议?
class Company_Googlemerchant_Block_Adminhtml_Products_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('gm_product_grid');
$this->setDefaultSort('id');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(false);
}
protected function _prepareCollection()
{
$storeId = 1;
$collection = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId);
$collection
->addAttributeToSelect('enable_googlemerchant')
->addAttributeToSelect('name')
->addAttributeToSelect('entity_id')
->addAttributeToSelect('type_id')
->addAttributeToSelect('status')
->addFieldToFilter('enable_googlemerchant', array( "eq" => '1') )
->addFieldToFilter('status', array( "eq" => '1') )
->addAttributeToSort('name', 'asc')
;
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('id', array(
'header' => Mage::helper('googlemerchant')->__('ID'),
'align' =>'left',
'index' => 'entity_id',
'width' => '100px',
));
$this->addColumn('product_name', array(
'header' => Mage::helper('googlemerchant')->__('Product Name'),
'align' =>'left',
'index' …Run Code Online (Sandbox Code Playgroud) $event = $fieldset->addField('parent_id', 'select', array(
'label' => Mage::helper('gallery')->__('Parent'),
'required' => true,
'name'=>'parent_id',
'values'=>$ac,
'onchange'=>'CheckSelectedItem()',
));
$event->setAfterElementHtml('<script>
function CheckSelectedItem()
{
var ddllist= window.document.getElementById("parent_id");
var itemName= ddllist.options[ddllist.selectedIndex].value;
Run Code Online (Sandbox Code Playgroud)
如何在form.php上为驻留在名为"gallerydata.php"的根文件夹中的文件进行ajax调用.我有一个名为"gallery"的扩展程序,用于从后端上传图像.所以我想通过使用ajax从下拉列表中获取一个艺术家的ID,这会调用该文件"gallerydata.php".
if(window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
xmlhttp1=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET","http://122.170.97.189:81/electriccityusa/gallerydata.php?q="+itemName,true);
}
</script>');
Run Code Online (Sandbox Code Playgroud) 你可以帮帮我吗?我正在尝试使用观察者在admin中向订单网格添加新列.有我的config.xml
<adminhtml>
<events>
<adminhtml_block_html_before>
<observers>
<order_grid>
<type>model</type>
<class>Order_Grid_Model_Observer</class>
<method>addItemsColumn</method>
</order_grid>
</observers>
</adminhtml_block_html_before>
</events>
</adminhtml>
Run Code Online (Sandbox Code Playgroud)
有我的观察者代码:
class Order_Grid_Model_Observer
{
public function addItemsColumn($observer)
{
$_block = $observer->getBlock();
$_type = $_block->getType();
if ($_type == 'adminhtml/sales_order_grid') {
$_block->addColumn('total_item_count', array(
'header'=> Mage::helper('sales')->__('Items'),
'width' => '80px',
'type' => 'text',
'index' => 'total_item_count',
'sortable' => false,
'filter' => false
));
$_block->getColumn('real_order_id')
->setData('filter_index', 'main_table.increment_id');
$collection = $_block->getCollection();
$collection->clear();
$collection->getSelect()
->joinLeft(array('o' => 'sales_flat_order'), 'o.entity_id = main_table.entity_id', array('total_item_count'));
$_block->setCollection($collection);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我几乎做到了,但是当我尝试按某个字段对网格进行排序时,我得到错误"字段列表中的列'increment_id'是不明确的".这很奇怪,因为我已经为'increment_id'字段更新了'filter_index'.为什么收集这个块的任何想法没有更新?谢谢.
我正在尝试编写一个自定义操作来运行我已构建的管理网格.是否可以通过get或post从网格中的列向控制器发送值?
我试过谷歌搜索,但我无法在任何地方找到适当的解释.如果可用,链接到列设置的说明('getter','type'等)也很有用.
此功能设置Magento网格以显示具有相应"删除"操作的文件名列表.
问题是删除操作永远不会传递参数'filename'.(参见http://www.premasolutions.com/content/magento-manage-category-product-grid-edit-link)我有TESTDUMP用于验证,但它永远不会打印在下一页上.
'params'是'addColumn-> actions-> url'的合法行为吗?
更新:为控制器添加了构造和准备集合.也许是因为我正在使用的收藏类型?
Rogue_Googlemerchant_Block_Adminhtml_Exporter_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('googlemerchantGrid');
// This is the primary key of the database
$this->setDefaultSort('filename');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
}
protected function _prepareCollection()
{
$basePath = Mage::getBaseDir('base');
$feedPath = $basePath . '/opt/googlemerchant/';
$errPath = $basePath . '/var/log/googlemerchant/';
$flocal = new Varien_Io_File();
$flocal->open(array('path' => $feedPath));
$dataCollection = new Varien_Data_Collection();
foreach ($flocal->ls() as $item) {
$dataObject = new Varien_Object();
$dataObject->addData(
array(
'filename' => $item['text'],
'size' => $item['size'] / 1000 …Run Code Online (Sandbox Code Playgroud)