0

I am making a custom module somewhat like this. This module has functionality to add products from customer account both in frontend and backend. I have created customer groups seller, general. Till now everything seems working on track, but in product grid i want to display customer name that which customer has uploaded this product, `how should i identify customer group and show its name in product grid.

Points I need to achieve:

  1. Make a custom grid which shows customer wise product, it should look like default product grid but it should contain customer name column.

Any help would be appreciated.

  • what you want to show? customer name / customer group name or both? – MauroNigrele Jan 19 '16 at 6:52
  • I want to show customer name. – Soeb Safi Jan 19 '16 at 6:53
  • but you need to track the customer group of that customer somewhere, right? – MauroNigrele Jan 19 '16 at 6:55
  • I have created a group called "SELLER" and created a customer under that group. Now i have a seller id which i want to bind with products grid. – Soeb Safi Jan 19 '16 at 6:58
  • fine! check my answer – MauroNigrele Jan 19 '16 at 7:45
1

If you want to show such data in product list without loose performance I think that the best way could be:

  1. Create the 'customer_name' product attribute (and set it as "show in product listing"

  2. Create another attribute for track the customer_id (If you need to track other customer data somewhere) this attribute must have the 'show in product listing' option disabled.

  3. Then add an observer hooked to catalog_product_save_before event and add the customer data to the product there, you can grab customer data from Mage::getSigleton('customer/session')->getCustomer()->getCustomerId() / ->getCustomerName() in frontend (I don´t know how are you persisting the customer data in the backend) - NOTE: remember that you can use different observers for the same event for front and backend, if you need.

  4. In the product list template just print the customer_name attribute as any other getCustomerName() ?>

That way you can ensure that you aren't adding any overhead to the product list dispatch, and setting the attribute as "show in product list" you will still viewing the customer name if you are using the "flat catalog product" feature.

TIP: You can set the product attribute as "system" to avoid the need of manually add it to all attribute sets.

  • I have used your suggested code and it worked for me. Now my product grid is showing customer name. THANK YOU SO MUCH. – Soeb Safi Jan 19 '16 at 12:04

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.