public function listsAction()
 {
     if ($this->request->isGet()) {
         echo json_encode(Products::find()->toArray());
         exit;
         var_dump(Products::find()->toArray());
         exit;
     }
     echo json_encode(array('status' => '404 bad request'));
     exit;
 }
Example #2
0
 public function afterSave()
 {
     $productRefModel = new ProductRef();
     $name = $this->getDI()->getRequest()->getPost()['name'];
     $productsModel = Products::find()->getLast();
     // var_dump($id->getId());
     //exit;
     //        var_dump($this->generateRefCode($id->getId($id->getId())));exit;
     $productRefModel->setRef($this->generateRefCode($productsModel->getId()))->setProductId($productsModel->getId());
     $productRefModel->save();
 }