简体   繁体   中英

Magento: Replace Image Label (Title) with Product Name

I have 3000+ products in Mangento that I imported from Excel. I have added images of about 1500+ products. However, I just realized that I did not fill in any of the Image Labels (Titles). I want to fill it in because of SEO.

Is there anyway to fill the Image Labels with Product Name?

I am not sure if it can be done from Mysql or has to be done by writing a script.

I have no programming backgound so any help would be appreciated.

Kevin.

There are two possible solutions:

Upload it through Dataflow

This is my preferred solution because you can choose to differ the alt at some point should your SEO team decide to use more robust keywording.

Using the following csv file format (the store column is important as admin is default for all store views):

sku, store, image_label, small_image_label, thumbnail_label
SKU001, admin, "my big image label", "my small image label", "my thumb label"

Output it in your theme

This is the quick-and-dirty and will cover all of your products in one go. My code sample below actually prefers the image label over top of the product name if it is set.

Have it default if it doesn't exist in your theme - in app/design/frontend/[yourtheme]/default/catalog/product/view/media.phtml :

<?php $_label = ($_product->getImageLabel() != '' ? $_product->getImageLabel() : $_product->getName()); ?>
<img src="<?php echo $this->helper( 'catalog/image' )->init( $_product, 'image')->resize( $imgWidth, $imgHeight ); ?>"
    height="<?=$imgHeight?>"
    width="<?=$imgWidth?>"
    alt="<?php echo $this->htmlEscape( $_label ); ?>"
    title="<?php echo $this->htmlEscape( $_label ) ; ?>" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM