1

I want to add a watermark to my images in the store. But when a dealer is logged in, he must see the original images. The dealer are in the customer group Dealers.

Is it possible to hide the watermark for the dealers / a customer group?

I have been searching for this, but I cannot find it.

1
  • Please be more specific. Are wholesalers a specific store, or customer group. how are they identified by the system Commented Dec 11, 2014 at 11:29

1 Answer 1

1

The water mark is set in the method Mage_Catalog_Helper_Image::init by these lines:

    $this->setWatermark(
        Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_image")
    );
    $this->setWatermarkImageOpacity(
        Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity")
    );
    $this->setWatermarkPosition(
        Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_position")
    );
    $this->setWatermarkSize(
        Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_size")
    );

You can try to rewrite this method and wrap the code above in an if statement that checks if the current user belongs to a certain group.
Something like this:

$dealerCustomerGroupIds = array(9, 10);
if (!in_array(Mage::getSingleton('customer/session')->getCustomerGroupId(),  $dealerCustomerGroupIds)) {
    //the code from above goes here
}

Of course this is a quick and dirty way of doing it. It would be cleaner to have a field in the system->configuration from where you can select the user groups that should not see watermarks. Then read that setting and populate the $dealerCustomerGroupIds variable. I just added the code here as a proof of concept.

4
  • Where can I find this method Marius?
    – RobinV91NL
    Commented Dec 11, 2014 at 14:19
  • I stated in the answer. Class Mage_Catalog_Helper_Image. If you want the file is app/code/core/Mage/Catalog/Helper/Image.php. But please don't edit the core. Rewrite the class. Here is a tutorial on how to do that
    – Marius
    Commented Dec 11, 2014 at 14:26
  • Thanks! It works. There is one small error in the code. The arrayname where you declare the array and in the if aren't the same. If they are both $dealerCustomerGroupIds it works fine!
    – RobinV91NL
    Commented Dec 11, 2014 at 15:50
  • @RobinV91NL. Sorry for that. I didn't test the code. I will fix it immediately.
    – Marius
    Commented Dec 11, 2014 at 15:50

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.