0

Hey guys I'm using this extension: https://amasty.com/sales-reps-and-dealers.html

It works beautifully but I want to make some adjustments. Essentially it creates sales reps/dealers that can have their own customers under them. Here is a visual diagram:

                               Our Awesome Company
                              /        |         \
                           Dealer1     |        Dealer2
                             /         |           \
                        Customers1    Customers2    Customers3

Our company can see all customers from groups 1,2,3.

Dealer1 can only see Customers1 and Dealer2 can only see Customers3

From what I know about SQL the customers must be linked in some way to their dealers, how would I go about checking who their dealers are? I'm hoping I can find their relation in a SQL search and eventually figure out a way to call getData('something') to see a customer's dealer.

Let me know if I can clarify my question in anyway! I tried to explain everything in a way where people without this extension could help out too.

1

Take a look at table am_perm

perm_id | uid | cid

Where:

'uid' = magento admin id 
'cid' = customer id.

To look up dealer by order id

Mage::getModel('amperm/perm')->getUserByOrder($orderId);

Mage::helper('amperm')->getCurrentSalesPersonId()

To lookup a dealer by customer Id

$perm = Mage::getModel('amperm/perm')->load($customerId, 'cid');

if($perm->getId()){
   $adminUser = Mage::getModel('admin/user')->load($perm->getUid());
   echo $adminUser->getFirstname();
}
4
  • If I'm logged in as a customer/user is there no way to see my dealer? Or can I only access it by orderId? If possible I want to see the dealer in the customer's dash board! Thanks for answering btw! – CodingMageSheen Nov 11 '16 at 20:00
  • omg you're awesome. I'm checking the database through my cPanel. Is there a way from a customers dashboard to see who their dealer or 'uid' is? Their cid from what I can tell is just the regular customersId. – CodingMageSheen Nov 11 '16 at 20:17
  • @CodingMageSheen .. take a look at my update – Renon Stewart Nov 11 '16 at 21:18
  • perfect thank you I've selected your answer! – CodingMageSheen Nov 11 '16 at 21:21

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.