2

How it is possible to copy all the characteristics below massively?

  • title -> meta title
  • title -> meta keywords
  • description -> meta description
  • Could it solve your problem? – sv3n Jan 23 '18 at 18:57
1

To set meta information on the fly (w/o save to product) you can use this ... It sets product name to meta title/keywords and description to meta description:

app/code/local/Your/Module/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Your_Module>
            <version>0.0.1</version>
        </Your_Module>
    </modules>
    <global>
        <models>
            <your_module>
                <class>Your_Module_Model</class>
            </your_module>
        </models>
    </global>
    <frontend>
        <events>
            <catalog_controller_product_view>
                <observers>
                    <test>
                        <class>your_module/observer</class>
                        <method>setMetaData</method>
                   </test>
                </observers>
            </catalog_controller_product_view>
        </events>
    </frontend>
</config>

app/code/local/Your/Module/Model/Observer.php

public function setMetaData(Varien_Event_Observer $observer)
{
    /* @var $product Mage_Catalog_Model_Product */
    $product = $observer->getProduct();

    $title = $product->getMetaTitle() ? $product->getMetaTitle() : $product->getName();
    $description = $product->getMetaDescription() ? $product->getMetaDescription() : $product->getDescription();
    $description = strip_tags($description);

    $product->setMetaTitle($title);
    $product->setMetaKeyword($title);
    $product->setMetaDescription($description);
}

You can also save this meta information to DB, but i use this (modified) on my own to still be able to filter products w/o meta data and set them manually later.

If you want it saved to product data, you can replace catalog_controller_product_view with catalog_product_save_before event.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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