Hi there,
I'm trying to code a new checkbox to be appended to the columns in the image gallery, beside "Disable". Its behavior would be the same as "Disable/Exclude" = Yes/No with entry in the database.
The idea is to add a "Use as page" checkbox for each image in the image gallery. The goal being to make a JS carousel with all pictures checked as "Use as page".
I have a few things done but I cannot :
- update data in the database => set 0 or 1 to the "page" field (see below)
- retrieve data from the database and then check/uncheck the checkbox depending on the "page" field.
--> So my question is : how to update data in the database and retrieve it in the checkbox (0 or 1 depending on the field value) ?
Thanks all for your very precious help.
Here is what I've done (1.4.1.0) :
1- Update table catalog_product_entity_media_gallery_value
Added a new field (which name is "page") :
- page tinyint(4) UNSIGNED No 0
2- Made the following changes to class Mage_Catalog_Model_Product_Attribute_Backend_Media
Line 49 :
from
$localAttributes = array('label', 'position', 'disabled');
to
$localAttributes = array('label', 'position', 'disabled', 'page');
Line 223 :
from
$data['disabled'] = (int) $image['disabled'];
to
$data['disabled'] = (int) $image['disabled'];
$data['page'] = (int) $image['page'];
Line 301
from
$mediaGalleryData['images'][] = array(
'file' => $fileName,
'position' => $position,
'label' => '',
'disabled' => (int) $exclude
);
to
$mediaGalleryData['images'][] = array(
'file' => $fileName,
'position' => $position,
'label' => '',
'disabled' => (int) $exclude,
'page' => (int) $exclude,
);
Line 328
from
$fieldsMap = array(
'label' => 'label',
'position' => 'position',
'disabled' => 'disabled',
'exclude' => 'disabled',
);
to
$fieldsMap = array(
'label' => 'label',
'position' => 'position',
'disabled' => 'disabled',
'exclude' => 'disabled',
'page' => 'disabled',
);
3- Made the following changes to template adminhtml/default/default/template/catalog/product/helper/gallery.phtml
Line 64
from
<th><?php echo Mage::helper('catalog')->__('Exclude') ?></th>
to
<th><?php echo Mage::helper('catalog')->__('Exclude') ?></th>
<th><?php echo Mage::helper('catalog')->__('Is Page') ?></th>
Line 77
from
<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>
to
<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>
Line 105
from
to
<td class="cell-disable"><input type="hidden" /> </td>
<td class="cell-page last"><input type="hidden" /> </td>