嘿伙计们,我如何在产品图片列表中再添加一个选项?像排除和删除复选框
2 回答
@vrnet您几乎就在那里...此外,您需要更新:
/js/mage/adminhtml/products.js(大量更改)。基本上你需要为 JSON 添加代码来处理你的新字段。我需要在最后添加第二个标签,最后复制粘贴标签代码并更改变量名称以匹配代码变量。应该很直截了当。
(第 66 行)Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Backend_Media 类,您需要添加新列,以便从数据库加载回来。
如果您有任何问题,请给我发电子邮件
我正在尝试编写相同的功能。你有答案吗?
这个想法是为图像库中的每个图像添加一个“用作页面”复选框。目标是制作一个 JS 轮播,所有图片都检查为“用作页面”。
我做了一些事情,但我无法更新数据库中的数据。
--> 所以我的问题是:如何更新数据库中的数据并在复选框中检索它(0 或 1 取决于复选框)?
感谢大家非常宝贵的帮助。
这是我所做的(1.4.1.0):
1- 更新表 catalog_product_entity_media_gallery_value
添加了一个新字段(名称为“page”):
- page tinyint(4) UNSIGNED 否 0
2- 对 Mage_Catalog_Model_Product_Attribute_Backend_Media 类进行了以下更改
第 49 行:
从
$localAttributes = array('label', 'position', 'disabled');
至
$localAttributes = array('label', 'position', 'disabled', 'page');
第 223 行:
从
$data['disabled'] = (int) $image['disabled'];
至
$data['disabled'] = (int) $image['disabled'];
$data['page'] = (int) $image['page'];
301线
从
$mediaGalleryData['images'][] = array(
'file' => $fileName,
'position' => $position,
'label' => '',
'disabled' => (int) $exclude
);
至
$mediaGalleryData['images'][] = array(
'file' => $fileName,
'position' => $position,
'label' => '',
'disabled' => (int) $exclude,
'page' => (int) $exclude,
);
328号线
从
$fieldsMap = array(
'label' => 'label',
'position' => 'position',
'disabled' => 'disabled',
'exclude' => 'disabled',
);
至
$fieldsMap = array(
'label' => 'label',
'position' => 'position',
'disabled' => 'disabled',
'exclude' => 'disabled',
'page' => 'disabled',
);
3- 对模板 adminhtml/default/default/template/catalog/product/helper/gallery.phtml 进行了以下更改
第 64 行
从
<th><?php echo Mage::helper('catalog')->__('Exclude') ?></th>
至
<th><?php echo Mage::helper('catalog')->__('Exclude') ?></th>
<th><?php echo Mage::helper('catalog')->__('Is Page') ?></th>
77号线
从
<td class="cell-disable a-center"><input type="checkbox" <?php if($_block->getElement()->getReadonly()):?> disabled="disabled"<?php endif;?> onclick="<?php echo $_block->getJsObjectName(); ?>.updateImage('__file__')" /></td>
至
<td class="cell-disable a-center"><input type="checkbox" <?php if($_block->getElement()->getReadonly()):?> disabled="disabled"<?php endif;?> onclick="<?php echo $_block->getJsObjectName(); ?>.updateImage('__file__')" /></td>
<td class="cell-page a-center"><input type="checkbox" <?php if($_block->getElement()->getReadonly()):?> disabled="disabled"<?php endif;?> onclick="<?php echo $_block->getJsObjectName(); ?>.updateImage('__file__')" /></td>
105 号线
从
至
<td class="cell-disable"><input type="hidden" /> </td>
<td class="cell-page last"><input type="hidden" /> </td>