How can I know if a grouped products contains any MAP products?
-
16-10-2019 - |
Pergunta
Basically I need to know if a grouped product contains any MAP sub product.
Is it possible to get this information without loading all product associated to it?
Solução
So, You need to check if any of the Grouped Product has a MAP set? You don't want to load all the product's because that can be slow.
The simplest suggestion I have is to gather all the Id's with
$ids = $product->getTypeInstance(true)->getAssociatedProductIds($product);
Then you can use
Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'attribute_code', $storeId);
Put it together. 'attribute_code'
=> needed Attribute's code && $storeId
$ids = $product->getTypeInstance(true)->getAssociatedProductIds($product);
foreach($ids as $id){
$wantedAttribute = Mage::getResourceModel('catalog/product')->getAttributeRawValue($id, 'attribute_code', $storeId);
if(SOME_CHECK){
DOSOMETHING;
}
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange