php - CakePHP model assosciation: View product image -
php - CakePHP model assosciation: View product image -
i have products model, , each product has several images. product-hasmany-image.
now when browse product able see images has not able view images when list products in index. how should first image product display in index?
the way can manage deal utilize image model within productscontroller guess not best option.
edit: of stuff after baked. default hasmany display when listing products?
model:
class product extends appmodel { var $hasmany = array( 'image' => array( 'classname' => 'image', 'foreignkey' => 'parent_id', 'dependent'=> false ), ); }
when have used bake script, index action have line in it:
$this->product->recursive = 0; this disable relations you've set. comment/remove line , should able display image (it should under $this->data['product']['image']).
php cakephp cakephp-appmodel
Comments
Post a Comment