English 中文(简体)
Magento product images new option
原标题:

Hey guys, how do i add one more option to product image list? like Exclude & Remove checkboxes

问题回答

@vrnet You were almost there... In addition, you would need to update:

  1. /js/mage/adminhtml/products.js (ton of changes). Basically you would need to add code for JSON to handle your new field. I needed to add a second label on my end and ended up copyPasting label code and changing the variable names to match the code variable. Should be pretty straight forward.

  2. (line 66) Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Backend_Media class, you would need to add your new column so that it would be loaded back from the DB.

If you have any questions, drop me an email

I m trying to code the same feature. Did you have an answer ?

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 picture checked as "Use as page".

I have a few things done but I cannot update data in the database.

--> So my question is : how to update data in the database and retrieve it in the checkbox (0 or 1 depending on the checkbox) ?

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" />&nbsp;</td>
            <td class="cell-page last"><input type="hidden" />&nbsp;</td>




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签