Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top