1

I am trying to create an eav attribute model. I create one for blog its working good as long as it has individual entity.

Now my question is how I can implement relationships using eav model. for example I have a table name theme which have ( themeId, themeName, themeImage) now I have another table which have product related to theme it looks like ( productId, productName, productImage, productDescription, fkThemeId )

   <resources>
        <planner_setup>
            <setup>
                <module>Opco_Planner</module>
                <class>Opco_Planner_Model_Resource_Setup</class>
            </setup>
        </planner_setup>
    </resources>

and installer looks like

$installer = $this;
$installer->startSetup();
$installer->addEntityType('planner_theme', array(
 ..............
));
$installer->endSetup();

How we can create multiple table along with resource setup and how we manage relationship are define above.

link or help in any way will be highly appreciated. thanks

4
  • by relationship you mean a many to many relationship or one to many? I mean your theme should have multiple products associated to it and a product should have multiple themes? Or how should it work?
    – Marius
    May 16 '16 at 13:30
  • In my case it will one to many but for understanding both because in future I might need it. May 16 '16 at 13:35
  • And how are your entities EAV since you have tables for each one of them with a field per attribute?
    – Marius
    May 16 '16 at 13:37
  • I have no idea how I am going to implement it. After creating first table these table were created planner_theme planner_theme_char planner_theme_datetime planner_theme_decimal planner_theme_int planner_theme_text planner_theme_varchar with attribute as I mentioned above ( themeId, themeName, themeImage ) now I am planing to create another one with relationship but have no idea how. May 16 '16 at 13:40
1

if you are trying to create a CRUD module with 2 entities and a relation between them, I can recommend the Ultimate Module Creator.
It should get you started (even more than that).
It allows you to create your entities just like you would create a table using PhpMyAdmin.
it allows you to decide between flat and EAV entities and even combine them in a single module.
It allows you to establish relations between your entities as many to many or one to many.
If you need a relation to products or categories, it handles that also.
Then you have to install the generated code over your magento instance.
Never use directly on production. The documentation can be found here.

I am involved in the development of the recommended extension but the extension is free and I get no financial benefits out of it.

5
  • Actually I want to understand how it works. No doubt extension is great. What if I create theme entity and now I want to add products to my theme like i did with configurable product how I am able to do it. May 17 '16 at 8:36
  • after creating model using your extension I am unable to access any controller every request end up with 404 page. In controller I have ( ThemeController, DecorationController ) with viewAction method. I try access it with "localsite/planner/theme/view" I am getting 404 error page. May 17 '16 at 12:52
  • are you trying to access the frontend or backend controller?
    – Marius
    May 17 '16 at 12:54
  • I am trying to access fronted controller. Please also I need your comment on my first comment as well. May 17 '16 at 13:46
  • for the view action in the frontend controller you need to specify a valid id planner/theme/view/id/3. For associating the products in a many to many relation with your theme you should see a separate tab when adding/editing a theme.
    – Marius
    May 17 '16 at 14:40

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.