Пример #1
0
 /**
  * Returns remains of this product in all active warehouses.
  * Note that if warehouse was added after product edit - it will not be shown here.
  * @return WarehouseProduct[]
  */
 public function getWarehousesState()
 {
     if ($this->activeWarehousesState === null) {
         $this->activeWarehousesState = WarehouseProduct::getDb()->cache(function ($db) {
             return WarehouseProduct::find()->where(['in', 'warehouse_id', Warehouse::activeWarehousesIds()])->andWhere('product_id=:product_id', [':product_id' => $this->id])->with('warehouse')->all();
         }, 86400, new TagDependency(['tags' => [ActiveRecordHelper::getObjectTag($this->className(), $this->id)]]));
     }
     return $this->activeWarehousesState;
 }