I am using a forced_shipping attribute and the below code in Mage\Shipping\Model\Carrier\Flatrate.php to restrict shipping method for items with the forced_shipping attribute set to Yes.
$items = Mage::getModel('checkout/session')->getQuote()->getAllItems();
$forcedShipping = false;
foreach ( $items as $item ) {
$_products = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('sku', $item->getSku())->addAttributeToSelect('forced_shipping', 'inner');
foreach ( $_products as $_product) {
if ( $_product->getForced_shipping() == 1 ) {
$forcedShipping = true;
}
}
}
if ( !$forcedShipping ) {
return false;
}
While this is working great with flat products disabled, it will fail once I enable them. How do I need to modify my code to make it work with flat products, is it possible at all?