$prod2toatt2 = new rtShopProductToAttribute();
    $prod2toatt2->setProductId($prod2->getId());
    $prod2toatt2->setAttributeId($att2->getId());
    $prod2toatt2->save();
} catch (Exception $e) {
    throw new sfException('Attributes could not be added to products! Please check.');
}
// Variations
try {
    $var1 = new rtShopVariation();
    $var1->setTitle('A1');
    $var1->setAttributeId($att1->getId());
    $var1->setPosition(1);
    $var1->save();
    $var2 = new rtShopVariation();
    $var2->setTitle('B1');
    $var2->setAttributeId($att2->getId());
    $var2->setPosition(1);
    $var2->save();
} catch (Exception $e) {
    throw new sfException('Variations could not be added! Please check.');
}
// Stocks
try {
    $stock1 = new rtShopStock();
    $stock1->setProductId($prod1->getId());
    $stock1->setQuantity(5);
    $stock1->setSku(mt_rand(1, 100000));
    $stock1->setPriceRetail(40);
    $stock1->save();
    $stock2 = new rtShopStock();
Exemplo n.º 2
0
    $var1->setTitle('A1');
    $var1->setAttributeId($att1->getId());
    $var1->setPosition(1);
    $var1->save();
    $var2 = new rtShopVariation();
    $var2->setTitle('A2');
    $var2->setAttributeId($att1->getId());
    $var2->setPosition(2);
    $var2->save();
    $var3 = new rtShopVariation();
    $var3->setTitle('B1');
    $var3->setAttributeId($att2->getId());
    $var3->setPosition(1);
    $var3->save();
    $var4 = new rtShopVariation();
    $var4->setTitle('B2');
    $var4->setAttributeId($att2->getId());
    $var4->setPosition(2);
    $var4->save();
    $t->pass('->save() on a rtShopVariation object works');
} catch (Exception $e) {
    $t->fail('->save() on a rtShopVariation failed!');
}
// Add stocks
try {
    $stock1 = new rtShopStock();
    $stock1->setProductId($prod1->getId());
    $stock1->setQuantity(5);
    $stock1->setSku(mt_rand(1, 10000));
    $stock1->setPriceRetail(100);
    $stock1->save();