1
I have a foreach that runs each product, then I would like to make a query in two tables from that ID, only I’m not getting, what I’m 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);
}
I’m printing the values but I get nothing :\
– Gustavo Souza
changed the script, try again...
– Danillo Victtor
My mistake, I was comparing the website_id with product_id, that was my mistake, your code is right, thank you.
– Gustavo Souza
Mark as answered please!
– Danillo Victtor
Three minutes to go.
– Gustavo Souza
Okay, thanks! Forget not... it’s important to me!
– Danillo Victtor
Let’s go continue this discussion in chat.
– Danillo Victtor