Exemplo n.º 1
0
 public function isRelatedTo(Product $product, $type)
 {
     return ProductRelationship::hasRelationship($product, $this, $type);
 }
Exemplo n.º 2
0
 public function testHasRelationship()
 {
     $product = array();
     foreach (range(1, 3) as $i) {
         $product[$i] = Product::getNewInstance($this->rootCategory, 'test');
         $product[$i]->save();
     }
     $relationship = ProductRelationship::getNewInstance($product[1], $product[2]);
     // Check relationship
     $this->assertFalse(ProductRelationship::hasRelationship($product[1], $product[2], ProductRelationship::TYPE_CROSS));
     $this->assertFalse(ProductRelationship::hasRelationship($product[1], $product[3], ProductRelationship::TYPE_CROSS));
     // Double check relationship to be sure that it is not being created by previous test
     $this->assertFalse(ProductRelationship::hasRelationship($product[1], $product[3], ProductRelationship::TYPE_CROSS));
     // Save and check again. Has relationship will return true if the record was set
     $relationship->save();
     $this->assertTrue(ProductRelationship::hasRelationship($product[1], $product[2], ProductRelationship::TYPE_CROSS));
     $this->assertFalse(ProductRelationship::hasRelationship($product[1], $product[3], ProductRelationship::TYPE_CROSS));
 }