1

I'm currently developing a custom module for Magento and theres one thing I´m not able to get working.

I have a front-end display of employees and an backend so I can add employees. I save the employees in a regular mysql table(so not EAV). Just to add employees to the database is no problem but now I want to add a different table so that the employees can be part of more than one category. I want to display the magento categories, and that I get working, but next I want to save that value along with the id of my employee in my own table in the database. Thats the problem i'm having.

I've tried using the magento admin grid and have a tab for adding and editing. I´ve tried to add a new tab and adding checkboxes there to check and save but can get it to work

Maybe I'm completely of, if that so youre free to suggest a different approach.

Balaji Kandasamy
  • 4,446
  • 10
  • 40
  • 58
cpuweb
  • 43
  • 1
  • 1
  • 6

1 Answers1

0

add this to save action

 if (isset($data['categories'])) {
                $data['categories'] = explode(',', $data['categories']);
                if (is_array($data['categories'])) {
                    $data['categories'] = array_unique($data['categories']);
                }
            }

and this to collection

 $this->getSelect()->join(
                        array('category_table' => $this->getTable('qbanner/qbanner_category')), 'main_table.qbanner_id = category_table.qbanner_id', array()
                )
                ->where('category_table.category_id = ?', $categoryId);
        return $this;

hope this will help you

liyakat
  • 11,825
  • 2
  • 40
  • 46
  • I didnt get it to work from your code, but it certainly got me thinking and I evolved my code and got some parts working. I mark your code as answer and will probably be starting a new question. – cpuweb Sep 25 '13 at 06:59
  • @cpuweb,glad to give you correct path.hope i can give you answer for your new question – liyakat Sep 25 '13 at 07:02