0

I have a magento store that sells products but in the meta description of every single product I want it to be formatted like this.

Product Name 1 Product Name 2 Product Name 3

Is there any possible way I could add automatically do this instead of manually?

Changing it to:

Sell Product Name 1 Here Sell Product Name 2 Here Sell Product Name 3 Here

I want to add words to the beginning and the end automatically of every single listing if possible, if anyone knows a way please let me know. Manually doing this would be a two year job.

2
  • Is the intention that the names be identical for every meta entry or are they dynamic based on a rule in some way/
    – philwinkle
    Commented Aug 1, 2014 at 20:28
  • If your problem was solved, please select one of the answers as "accepted" to mark this question as solved. magento.stackexchange.com/help/accepted-answer Commented Sep 10, 2014 at 19:40

4 Answers 4

2

To expand on pspahn's solution, I would do the following:

Create a one-off PHP script in the magento root folder called 'script.php' (or whatever you want).

<?php
require_once 'app/Mage.php';
Mage::app('default');

$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToSelect('meta_title');

foreach ($products as $product) {
    $product->setMetaTitle('Sell '.$product->getMetaTitle().' Here');
    $product->getResource()->saveAttribute($product, 'meta_title');
}

Then from bash (while current directory is magento root folder), run

php script.php

$product->getResource()->saveAttribute() is MUCH faster then calling save() on the original model, so your script would finish in I would guess about a tenth of the time. Also, I doubt the actual attribute is meta_title, probably description, or meta_description, so change the script accordingly.

0

You can do this with the "Update Attributes" feature of the Magento Catalog grid.

  1. Navigate to Catalog > Manage Products

  2. Select the products you wish to update with the checkbox, select Update Attributes from the dropdown and then click Submit

    enter image description here

  3. Update meta keywords and click Save

    enter image description here

6
  • This set the same value for each product.
    – Amasty
    Commented Aug 1, 2014 at 20:17
  • Having re-read the question is this not what was asked?
    – philwinkle
    Commented Aug 1, 2014 at 20:19
  • Having the same mata title for each product is is probably not the desired behavior. Does it make sense?
    – Amasty
    Commented Aug 1, 2014 at 20:22
  • Absolutely not. I agree with you.
    – philwinkle
    Commented Aug 1, 2014 at 20:26
  • Here is what I am talking about: imgur.com/1fnFXLo Several thousand products, each has a unique name, I want the names completely left in place and untouched, and ONLY add the words underlined in black to each without going into each "simple" or "configurable" product label.
    – user12829
    Commented Aug 1, 2014 at 21:21
0

You can rewrite block catalog-product-view and add the prefix and posfix for metas in the _prepareLayout method.

0

If your intention is to do this just once (since you want to change all the products to the new meta title) you can use something like the following (haven't tested this, and with thousands of products, it'll probably take a bit to finish):

$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToSelect('meta_title');

foreach ($products as $product) {
    $oldMeta = $product->getMetaTitle();
    $newMeta = "Buy " . $oldMeta . " Supplements Online"
    $product->setMetaTitle($newMeta);
    $product->save();
}

You could run this from your own module, as an external script, whatever you want. I've actually run some things like this just from whatever template I happen to have open. You're running it once and then getting rid of it.

Note that there are some spots if you place this code it will run multiple times for a single page load. Leaving you with something like "Buy Buy My Product Supplements Online Supplements Online". Make sure it is run just once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.