My dear collection,
The way you are relating the TAGs is not feasible, to do.
Think of bringing products with mandatory TAGs A, B and C, would have to have subquerys:
<?php
$criterios = array(
'Produto.publicado'=>1,
'Produto.titulo LIKE'=>"%$kw%",
'AND' => array(),
);
foreach ($tags as $tag){
$criterios['AND'][] = array('TagsProduto.tag_id'=>$tag);
}
?>
See above a way to do what you want, but it does not make sense, because TagsProduto.id has only 1 value in the line, or 1 ID of Product Tags per line.
To bring products with TAGs A, B and C, you have to do something like:
<?php
$prodTag = array();
foreach ($tags as $tag){
$prodTag[] = "Produto.id = (SELECT produto_id FROM tags_produto WHERE id={$tag} AND produto_id=Produto.id)";
}
$tags = implode(' AND ', $prodTags);
$this->Produto->find('all', array('conditions'=>array(
$tags,
)));
?>