Created
November 28, 2018 09:43
-
-
Save Luxato/f4fe5a349915bfd0bceb399f842544a3 to your computer and use it in GitHub Desktop.
Magento find product with attribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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