Produtos Relacionados

Asked

Viewed 73 times

1

Good afternoon. How do I make the chosen product not appear in the related products?

$stmtProdRel = $pdo->prepare("SELECT *  FROM produtos as p                                      
                                        WHERE p.produtos_situacao = 1 AND 
                                              p.produtos_categoria = :categoria");   
$stmtProdRel->bindParam(':categoria', $resultProd->produtos_categoria);
$stmtProdRel->execute();   
$resultProdRel = $stmtProdRel->fetchAll(PDO::FETCH_OBJ);
  • 1

    could explain better what your doubt?

  • https://atelieflordelis.com.br/product/acucena-aramada/14 --- I am making this site... but I want to take the product chosen above the related products

  • ok, but this select you put brings the related products?

  • Product chosen where or at what time?

  • @Maybe yes. Bring. I want the products does not appear in related.

  • @Bruno in the link I put in the comments. It appears as if I was seeing more information of the products. but I want it not to appear in related

Show 1 more comment

1 answer

3


Apparently, one of the ways to resolve this issue is via SQL. Pass the selected product to the code snippet you posted and add an delete condition to SQL.

For example, if the product has a code:

$stmtProdRel = $pdo->prepare("SELECT *  FROM produtos as p
                              WHERE p.produtos_situacao = 1 AND 
                              p.produtos_categoria = :categoria AND
                              p.produtos_codigo <> :codigo");
$stmtProdRel->bindParam(':categoria', $resultProd->produtos_categoria);
$stmtProdRel->bindParam(':codigo', $resultProd->produtos_codigo);
$stmtProdRel->execute(); 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.