jd440 Posted May 16, 2015 Share Posted May 16, 2015 Bonjour à tous. Pendant une période donné je vais répartir je vais devoir mettre une partit de mon stock non disponible à la vente. Pour cela j'avais pensé creer une override pour décaisser pendant la période donnée le stock non dispo, puis le réinjecter ensuite. quelque chos dans l'idée: public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null) { $stock_out = 1; // if null, it's a product without attributes if ($id_product_attribute === null) $id_product_attribute = 0; $key = 'StockAvailable::getQuantityAvailableByProduct_'.(int)$id_product.'-'.(int)$id_product_attribute.'-'.(int)$id_shop; if (!Cache::isStored($key)) { $query = new DbQuery(); $query->select('SUM(quantity)'); $query->from('stock_available'); // if null, it's a product without attributes if ($id_product !== null) $query->where('id_product = '.(int)$id_product); $query->where('id_product_attribute = '.(int)$id_product_attribute); $query = StockAvailable::addSqlShopRestriction($query, $id_shop); if($stock_out) { $query2 = new DbQuery(); $query2->select('SUM(quantity)'); $query2->from('stock_unavailable'); // if null, it's a product without attributes if ($id_product !== null) $query2->where('id_product = '.(int)$id_product); $query2->where('id_product_attribute = '.(int)$id_product_attribute); $query2 = StockAvailable::addSqlShopRestriction($query2, $id_shop); Cache::store($key, (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query)-(int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query2)); } else { Cache::store($key, (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query)); } } return Cache::retrieve($key); } Puis après j'ai repensé à la gestion des stock avancé. Est il possible des répartir dans ce sens el stock sur deux entrepot et rendre indisponible à la vente l'un des entrepot? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now