Would you have any way to get product SKUs from a category? For example, I have a category with id = 13
and I need to get the SKUs of these products dynamically, so I can do checks that I created in my code.
And I would need to save these SKUs of these products in an array so I can do a check in my code, as I currently "pick up" these SKUs manually by placing them in an array.
Code created in a controller:
public function isCartaoAddAction(){
$array_de_skus_de_cartoes = array(45,60,80,90,102,103,104,105); //SKUs products
$isCartaoAdicionado = 0;
$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
foreach ($array_de_skus_de_cartoes as $sku) {
if($sku == $item->getProduct()->getSku()) {
$isCartaoAdicionado = 1;
$cartao_id = Mage::getModel("catalog/product")->getIdBySku($sku);
}
}
}
if($isCartaoAdicionado == 1) {
echo json_encode(array('adicionado' => '1','id_produto' => $cartao_id));
} else {
echo json_encode(array('adicionado' => '','id_produto' => ''));
}
}