Skip to main content
added 78 characters in body
Source Link
SeStro
  • 774
  • 5
  • 16
function inStock($skus){
    if ($skus->getSize()) {
        $skusArray = array();
        foreach ($skus as $sku) {
            $skusArray[] = $sku->getSku();
            $requiredQtyArray[$sku->getSku()] = $sku->getSku();
        }

        $collection = Mage::getModel('catalog/product')
            ->getCollection()
            ->addAttributeToFilter('sku', array('in' => $skusArray));
        foreach ($collection as $product) {
            $quantity = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
            if ($quantity < $skurequiredQtyArray[$product->getRequiredQuantity>getSku()]) {
                return false;
            }
        }
    } else {
        return false;
    }
    return true;
}
function inStock($skus){
    if ($skus->getSize()) {
        $skusArray = array();
        foreach ($skus as $sku) {
            $skusArray[] = $sku->getSku();
        }

        $collection = Mage::getModel('catalog/product')
            ->getCollection()
            ->addAttributeToFilter('sku', array('in' => $skusArray));
        foreach ($collection as $product) {
            $quantity = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
            if ($quantity < $sku->getRequiredQuantity()) {
                return false;
            }
        }
    } else {
        return false;
    }
    return true;
}
function inStock($skus){
    if ($skus->getSize()) {
        $skusArray = array();
        foreach ($skus as $sku) {
            $skusArray[] = $sku->getSku();
            $requiredQtyArray[$sku->getSku()] = $sku->getSku();
        }

        $collection = Mage::getModel('catalog/product')
            ->getCollection()
            ->addAttributeToFilter('sku', array('in' => $skusArray));
        foreach ($collection as $product) {
            $quantity = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
            if ($quantity < requiredQtyArray[$product->getSku()]) {
                return false;
            }
        }
    } else {
        return false;
    }
    return true;
}
added 144 characters in body
Source Link
SeStro
  • 774
  • 5
  • 16
function inStock($skus){
    if ($skus->getSize()) {
        $skusArray = array();
        foreach ($skus as $sku) {
            $skusArray[] = $sku->getSku();
        }

        $collection = Mage::getModel('catalog/product')
            ->getCollection()
            ->addAttributeToFilter('sku', array('in' => $skus$skusArray));
        foreach ($collection as $product) {
            $quantity = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
            if ($quantity < $sku->getRequiredQuantity()) {
                return false;
            }
        }
    } else {
        return false;
    }
    return true;
}
function inStock($skus){
    if ($skus->getSize()) {
        $collection = Mage::getModel('catalog/product')
            ->getCollection()
            ->addAttributeToFilter('sku', array('in' => $skus));
        foreach ($collection as $product) {
            $quantity = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
            if ($quantity < $sku->getRequiredQuantity()) {
                return false;
            }
        }
    } else {
        return false;
    }
    return true;
}
function inStock($skus){
    if ($skus->getSize()) {
        $skusArray = array();
        foreach ($skus as $sku) {
            $skusArray[] = $sku->getSku();
        }

        $collection = Mage::getModel('catalog/product')
            ->getCollection()
            ->addAttributeToFilter('sku', array('in' => $skusArray));
        foreach ($collection as $product) {
            $quantity = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
            if ($quantity < $sku->getRequiredQuantity()) {
                return false;
            }
        }
    } else {
        return false;
    }
    return true;
}
Source Link
SeStro
  • 774
  • 5
  • 16

function inStock($skus){
    if ($skus->getSize()) {
        $collection = Mage::getModel('catalog/product')
            ->getCollection()
            ->addAttributeToFilter('sku', array('in' => $skus));
        foreach ($collection as $product) {
            $quantity = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
            if ($quantity < $sku->getRequiredQuantity()) {
                return false;
            }
        }
    } else {
        return false;
    }
    return true;
}