1

Can I set alternative names in upsell products list?

enter image description here

I would like to set an attribute "upsell_name" in CSV import so labels in red circles would be altered.

For example for product "Long name param1 param2", I would set "upsell_name" to "param1 param2".

  • Can you please give some feedback? Did it answer your question? – sv3n Jul 2 '17 at 8:29
1

Just add an extension with this code and adjust $product->setName(....) to your needs:

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

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <My_Module>
            <version>0.0.1</version>
        </My_Module>
    </modules>
    <global>
        <models>
            <my_module>
                <class>My_Module_Model</class>
            </my_module>
        </models>
    </global>
    <frontend>
        <events>
            <catalog_product_upsell>
                <observers>
                    <set_upsell_names>
                        <class>my_module/observer</class>
                        <method>changeUpsellNames</method>
                    </set_upsell_names>
                </observers>
            </catalog_product_upsell>
        </events>
    </frontend>
</config>

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

<?php
class My_Module_Model_Observer extends Mage_Core_Model_Observer
{
    public function changeUpsellNames(Varien_Event_Observer $observer)
    {
        if ($collection = $observer->getCollection()) {
            foreach ($collection as $product) {
                $product->setName($product->getData('upsell_name'));
            }
        }
    }
}

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.