1

Can someone tell me how to create separate login with product add/upload and a few other merchant related features for merchants? Please notice that merchants are those users who will be able to login from their accounts and can upload their products to sell on our website. Those uploaded products will first be visible to admin for review and if admin deems those uploaded products as appropriate he can make them available for selling. Is there any built in feature for this in Magento or is there any extension/module for this feature or a new customised extension will have to be developed? Any suggestions or help? Thanks.

2
  • Hi, Welcome to Magento SA, please try to only ask 1 question. Instead of bundleing it together.
    – Vic
    Commented Apr 21, 2014 at 7:16
  • Hi Vic, actually the question is only one and simple but may not look like that. The question is how to create separate login for merchants? The last part of the question actually gives three possible answers to my question. But as I'm very new to Magento I was not sure. I hope now the question is more clear? Thanks.
    – Rolen Koh
    Commented Apr 21, 2014 at 7:31

1 Answer 1

1

It is possible. You'd want to create a specific user with access to only specific roles, you can read more about that over here:

Setting Up Admin Users and Roles in Magento CE 1.8 and EE 1.13

From what you've explained, this user should only have access to the catalog product add features, which can easily be set up.

Thereafter, you'd want to set up your own event-observer module to observe catalog_product_save_after, which is the event fired after saving a product. Your observer will automatically set any product added by a "Merchant" user to disabled immediately after they create it.

Your event-observer will look like this:

app/etc/modules/Xyz_Catalog.php:

<?xml version="1.0"?>
<config>
<modules>
<Xyz_Catalog>
  <codePool>local</codePool>
  <active>true</active>
</Xyz_Catalog>
</modules>
</config>

app/code/local/Xyz/Catalog/etc/config.xml:

<?xml version="1.0"?>
<config>
<global>
<models>
    <xyzcatalog>
         <class>Xyz_Catalog_Model</class>
    </xyzcatalog>
</models>
<events>
  <catalog_product_save_after>
    <observers>
      <xyz_catalog_model_observer>
        <type>singleton</type>
        <class>Xyz_Catalog_Model_Model_Observer</class>
        <method>disable_product</method>
      </xyz_catalog_model_observer>
    </observers>
  </catalog_product_save_after>     
</events>

app/code/core/local/Xyz/Catalog/Model/Observer.php:

<?php
class Xyz_Catalog_Model_Observer
{
    public function disable_product($observer){
        $admin_user_session = Mage::getSingleton('admin/session');
        $adminuserId = $admin_user_session->getUser()->getUserId();
        $role_data = Mage::getModel('admin/user')->load($adminuserId)->getRole()->getData();
        $role_name = $role_data['role_name'];
        if ($role_name == 'merchant'){
            $product = $observer->getEvent()->getProduct();
            $product->setStatus(2); //2 = disabled
            $product->save();
        }
    }
}

And voila, you're all set.

To test that it is up and running, create an example user, log in and try add a product. After you save it, you should see that the system has automatically disabled it.

If everything is working as you expected, all you need to do is create a couple of these "merchant users", send the login details to your clients and you should be ready to rock and roll.

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.