Example #1
0
 /**
  * Relates photos to this product
  *
  * @return null
  */
 public function action_photos()
 {
     $id = arr::get($_GET, 'id');
     $this->request->response = new View_Admin_Product_Photos();
     $this->request->response->bind('product', $product);
     $this->request->response->bind('errors', $errors);
     $product = new Model_Vendo_Product($id);
     if ($_POST) {
         $product->remove_all('vendo_photos');
         $product->relate('vendo_photos', arr::get($_POST, 'photos', array()));
         $product->primary_photo_id = arr::get($_POST, 'primary_photo_id', NULL);
         $product->save();
         $this->request->response->success = 'You have assigned the photos';
     }
 }
Example #2
0
 /**
  * Tests to ensure that a saved order cannot have new products added to it
  *
  * @return null
  */
 public function test_saved_order_is_fixed()
 {
     // Create a new product first
     $product = new Model_Vendo_Product();
     $product->set_fields(array('name' => 'Unit Test', 'price' => '9.99', 'description' => 'This is a unit test.', 'order' => '1'));
     $product->save();
     $order = new Model_Order();
     $order->user_id = self::$user->id;
     $order->address_id = self::$user->address_id;
     $order->contact_id = self::$contact->id;
     $order->add_product($product, 1);
     $order->save();
     try {
         $order->add_product($product, 1);
     } catch (Exception $e) {
         $this->assertEquals('Saved orders cannot be modified!', $e->getMessage());
         $order->delete();
         $product->delete();
         return;
     }
     $order->delete();
     $product->delete();
     $this->fail('Orders cannot be modified once saved.');
 }