# Associations to and from plugin

**URL:** <https://discourse.cakephp.org/t/associations-to-and-from-plugin/8661>\
**Category:** Need Help\
**Created:** [November 26, 2020, 10:38am UTC](https://discourse.cakephp.org/t/associations-to-and-from-plugin/8661 "2020-11-26T10:38:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![6120](https://avatars.discourse-cdn.com/v4/letter/6/278dde/32.png) [@6120](https://discourse.cakephp.org/u/6120)\
**Post date:** [November 26, 2020, 10:38am UTC](https://discourse.cakephp.org/t/associations-to-and-from-plugin/8661/1 "2020-11-26T10:38:15Z")

</div>

CakePHP 3.x  
Hello everybody.  
This is not the first time I get into trouble with plugin associations.  
So I have Categories hasMany Articles =\> works fine  
Articles hasMany Categories =\> works fine  
Then  
Articles hasOne plugin Boutique \> Options =\> does not work  
and plugin \> Options belongTo Articles =\> does not work

Code for Articles table :  
$this-\>hasMany(‘Formats’, [  
‘foreignKey’ =\> ‘article\_id’,  
‘className’ =\> ‘Boutique.Articles’  
]);  
$this-\>hasMany(‘Options’, [  
‘foreignKey’ =\> ‘article\_id’,  
‘className’ =\> ‘Boutique.Articles’  
]);

All code (in models) comes from bake.  
another example :  
in options controller :  
‘contain’ =\> [  
‘Articles’ =\> [‘fields’ =\> [‘Articles.id’, ‘Articles.category\_id’, ‘Articles.name’, ‘Articles.forsale’]],  
‘Articles.Categories’ =\> [‘fields’ =\> [‘Categories.id’, ‘Categories.name’]],  
‘Articles.Options’ =\> [‘fields’ =\> [‘Options.id’, ‘Options.article\_id’, ‘Options.tva\_id’]]  
]  
does not work either.

debugger says :  
Articles is not associated with Categories  
or Articles is not associated with Options
