I have a foreach that runs each product, then I would like to do a query on two tables from that ID, but I'm not getting it, what am I doing wrong?
$collection = Mage::getModel('catalog/product')->getCollection();
foreach ($collection as $key => $produto) {
$id = $produto->getId();
$produto_loaded = Mage::getModel('catalog/product')->load($id);
$id_prd = $produto_loaded->getId();
$teste = $id_prd;
$link = mysqli_connect('localhost','root','','teste2');
$link->set_charset("utf8");
$query =
"SELECT catalog_product_website.website_id as websiteid, catalog_category_product.category_id as categoria, catalog_category_product.position as positioncat
FROM catalog_product_website
INNER JOIN catalog_category_product
ON catalog_product_website.websiteid = catalog_category_product.product_id
WHERE n.websiteid = '$teste'";
$select = mysqli_query($link, $query);
while ($row = mysqli_fetch_array($select)) {
$test = array(
$row['websiteid'],
$row['categoria'],
$row['positioncat']);
print_r($test);
}