}
// Product to attribute
try {
    $prod1toatt1 = new rtShopProductToAttribute();
    $prod1toatt1->setProductId($prod1->getId());
    $prod1toatt1->setAttributeId($att1->getId());
    $prod1toatt1->save();
    $prod1toatt2 = new rtShopProductToAttribute();
    $prod1toatt2->setProductId($prod1->getId());
    $prod1toatt2->setAttributeId($att2->getId());
    $prod1toatt2->save();
    $prod2toatt1 = new rtShopProductToAttribute();
    $prod2toatt1->setProductId($prod2->getId());
    $prod2toatt1->setAttributeId($att1->getId());
    $prod2toatt1->save();
    $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');
 public function savertShopAttributesList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['rt_shop_attributes_list'])) {
         // somebody has unset this widget
         return;
     }
     if (null === $con) {
         $con = $this->getConnection();
     }
     Doctrine_Query::create()->from('rtShopProductToAttribute pta')->andWhere('pta.product_id = ?', $this->object->id)->delete()->execute();
     $values = $this->getValue('rt_shop_attributes_list');
     if (!is_array($values)) {
         $values = array();
     }
     if (count($values)) {
         $i = 0;
         foreach ($values as $v) {
             $rt_product_to_attribute = new rtShopProductToAttribute();
             $rt_product_to_attribute->setProductId($this->object->id);
             $rt_product_to_attribute->setAttributeId($v);
             $rt_product_to_attribute->setPosition($i);
             $rt_product_to_attribute->save();
             $i++;
         }
     }
 }