本文整理汇总了PHP中StockAvailable::postSave方法的典型用法代码示例。如果您正苦于以下问题:PHP StockAvailable::postSave方法的具体用法?PHP StockAvailable::postSave怎么用?PHP StockAvailable::postSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockAvailable
的用法示例。
在下文中一共展示了StockAvailable::postSave方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeProductFromStockAvailable
/**
* Removes a given product from the stock available
*
* @param int $id_product
* @param int $id_product_attribute Optional
* @param mixed $id_shop shop id or shop object Optional
*/
public static function removeProductFromStockAvailable($id_product, $id_product_attribute = null, $shop = null)
{
if (!Validate::isUnsignedId($id_product)) {
return false;
}
if (Shop::getContext() == SHOP::CONTEXT_SHOP) {
if (Shop::getContextShopGroup()->share_stock == 1) {
$pa_sql = '';
if ($id_product_attribute !== null) {
$pa_sql = '_attribute';
$id_product_attribute_sql = $id_product_attribute;
} else {
$id_product_attribute_sql = $id_product;
}
if ((int) Db::getInstance()->getValue('SELECT COUNT(*)
FROM ' . _DB_PREFIX_ . 'product' . $pa_sql . '_shop
WHERE id_product' . $pa_sql . '=' . (int) $id_product_attribute_sql . '
AND id_shop IN (' . implode(',', array_map('intval', Shop::getContextListShopID(SHOP::SHARE_STOCK))) . ')')) {
return true;
}
}
}
$res = Db::getInstance()->execute('
DELETE FROM ' . _DB_PREFIX_ . 'stock_available
WHERE id_product = ' . (int) $id_product . ($id_product_attribute ? ' AND id_product_attribute = ' . (int) $id_product_attribute : '') . StockAvailable::addSqlShopRestriction(null, $shop));
if ($id_product_attribute) {
if ($shop === null || !Validate::isLoadedObject($shop)) {
$shop_datas = array();
StockAvailable::addSqlShopParams($shop_datas);
$id_shop = (int) $shop_datas['id_shop'];
} else {
$id_shop = (int) $shop->id;
}
$stock_available = new StockAvailable();
$stock_available->id_product = (int) $id_product;
$stock_available->id_product_attribute = (int) $id_product;
$stock_available->id_shop = (int) $id_shop;
$stock_available->postSave();
}
return $res;
}