本文整理汇总了PHP中Ess_M2ePro_Model_Magento_Product::calculateStockAvailability方法的典型用法代码示例。如果您正苦于以下问题:PHP Ess_M2ePro_Model_Magento_Product::calculateStockAvailability方法的具体用法?PHP Ess_M2ePro_Model_Magento_Product::calculateStockAvailability怎么用?PHP Ess_M2ePro_Model_Magento_Product::calculateStockAvailability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ess_M2ePro_Model_Magento_Product
的用法示例。
在下文中一共展示了Ess_M2ePro_Model_Magento_Product::calculateStockAvailability方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVariationsStockAvailabilities
private function getVariationsStockAvailabilities(array $variationsProductsIds)
{
$productsIds = array();
foreach ($variationsProductsIds as $variationProductsIds) {
foreach ($variationProductsIds as $variationProductId) {
$productsIds[] = $variationProductId;
}
}
$productsIds = array_values(array_unique($productsIds));
$catalogInventoryTable = Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item');
$select = $this->_getReadAdapter()->select()->from(array('cisi' => $catalogInventoryTable), array('product_id', 'is_in_stock', 'manage_stock', 'use_config_manage_stock'))->where('cisi.product_id IN (' . implode(',', $productsIds) . ')');
$stocks = $select->query()->fetchAll();
$variationsProductsStocks = array();
foreach ($variationsProductsIds as $key => $variationProductsIds) {
foreach ($variationProductsIds as $id) {
$count = count($stocks);
for ($i = 0; $i < $count; $i++) {
if ($stocks[$i]['product_id'] == $id) {
$stockAvailability = Ess_M2ePro_Model_Magento_Product::calculateStockAvailability($stocks[$i]['is_in_stock'], $stocks[$i]['manage_stock'], $stocks[$i]['use_config_manage_stock']);
$variationsProductsStocks[$key][] = $stockAvailability;
break;
}
}
}
}
$variationsStocks = array();
foreach ($variationsProductsStocks as $key => $variationProductsStocks) {
$variationsStocks[$key] = min($variationProductsStocks);
}
return $variationsStocks;
}