我正在尝试实现嵌入式小部件.管理员将能够配置此窗口小部件并将其嵌入到WYSIWYG编辑器中.许多配置选项中有两个是应该显示在前端和类别列表中的产品列表.
我想通过" adminhtml/catalog_product_widget_chooser "和" adminhtml/catalog_category_widget_chooser " 允许这个选择.我尝试使用Web上提供的稀疏文档来实现这些小部件,但我设法完成的只是选择一个产品或选择一个类别的实现.我需要多选行为.
据我所知,目前的实施不允许多选的可能性.我检查了类和grid.phtml模板的代码,它接缝很糟糕,并且不能超出当前的使用意图.例如,您可以假设初始化窗口小部件参数的辅助块以允许多个选择:
<helper_block>
<type>adminhtml/catalog_product_widget_chooser</type>
<data>
<button translate="open">
<open>Select Products...</open>
</button>
<use_massaction>1</use_massaction>
</data>
</helper_block>
Run Code Online (Sandbox Code Playgroud)
但是产品选择器是硬编码的,无需使用这部分代码进行大规模操作:
public function prepareElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$uniqId = Mage::helper('core')->uniqHash($element->getId());
$sourceUrl = $this->getUrl('*/catalog_product_widget/chooser', array(
'uniq_id' => $uniqId,
'use_massaction' => false,
));
...
Run Code Online (Sandbox Code Playgroud)
而应该有某种按钮来确认多项选择的grid.phtml模板只显示"搜索"和"重置过滤器"按钮.并没有添加另一个按钮的处理.例如,这里是负责打印按钮html的默认代码:
public function getMainButtonsHtml()
{
$html = '';
if($this->getFilterVisibility()){
$html.= $this->getResetFilterButtonHtml();
$html.= $this->getSearchButtonHtml();
}
return $html;
}
Run Code Online (Sandbox Code Playgroud)
默认情况下,仅打印这两个按钮.
所以我基于上面提到的两个实现开始了我自己的实现,它变得丑陋,最终可能成为一个难以维护的复制意大利面.我的原则是,如果事情看起来很难看,那么我做错了.
那么有一种直接的方法可以通过使用网格小部件在小部件配置屏幕上实现多个产品和多个类别选择吗?
我正在尝试从几个域进行AJAX调用到一个将处理请求的域.通过在处理服务器上设置标头,可以轻松在Firefox和Chrome中启用跨域:
header("Access-Control-Allow-Origin: *");
Run Code Online (Sandbox Code Playgroud)
但这无助于在Internet Explorer中启用它.当我尝试:
httpreq.send('');
Run Code Online (Sandbox Code Playgroud)
它会因错误访问被拒绝而停止.
如何在Internet Explorer中启用它?
我正在尝试从目录中删除产品.
每当我尝试使用管理界面(质量或单一操作)删除产品时,它会抛出500内部服务器错误.每当我尝试使用脚本(以编程方式)删除产品时,它只会挂起删除方法调用.
即使打开了日志记录,也不会显示错误输出,也不会抛出异常并且日志也是静默的.
这是我在脚本中使用的示例代码:
//...
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('sku')
->addStoreFilter($store_id);
$collection->load();
// collection is not empty I checked
foreach ($collection as $product) {
try {
$product->delete(); // this is the line where it hangs
print $product->getSku() . " deleted" . PHP_EOL;
} catch (Exception $e) {
print $e->getMessage();
}
}
Run Code Online (Sandbox Code Playgroud)
有没有人有这样的经历,可能是什么原因?
这是Magento Enterprise 1.11,据我所知,它对应于Magento Community 1.6.