示例#1
0
 public function __construct($id = null)
 {
     parent::__construct();
     if ($id == null) {
         //throw new NotFoundHttpException('NOT valid main product.');
     } else {
         $mainProduct = Product::findOne($id);
         if ($mainProduct->stock_qty == null || $mainProduct->qty_per_order != 1) {
             throw new NotFoundHttpException('NOT valid main product.');
         } else {
             //$this->setAttributes($mainProduct->getAttributes());
             $this->scenario = 'batch';
             $this->attributes = $mainProduct->getAttributes();
             $this->qty_per_order = 2;
             $this->stock_qty = null;
         }
     }
 }