Skip to content

Instantly share code, notes, and snippets.

@Luxato
Created November 28, 2018 09:43
Show Gist options
  • Save Luxato/f4fe5a349915bfd0bceb399f842544a3 to your computer and use it in GitHub Desktop.
Save Luxato/f4fe5a349915bfd0bceb399f842544a3 to your computer and use it in GitHub Desktop.
Magento find product with attribute
<?php
for ($i = 1; $i < 12; $i++) {
$cartProductsCollection = Mage::getModel('catalog/product')->getCollection()
->addStoreFilter($this->getStoreId())
->addAttributeToSelect('*')->setPageSize( 1000 )
->setCurPage( $i );
// FIND PRODUCT WITH COLOR ATTRIBUTE
foreach ( $ProductsCollection as $product) {
$attributes = $product->getAttributes();
foreach ( $attributes as $attribute) {
if ($attribute->getAttributeCode() == 'newclothingsize') {
if ($attribute->getFrontend()->getValue($product) != 'Nej' && $attribute->getFrontend()->getValue($product) != '') {
echo "Color product id is " . $product->getId();
echo " and the color is " . $attribute->getFrontend()->getValue($product);
exit;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment