public function savertShopProductsList($con = null) { if (!$this->isValid()) { throw $this->getErrorSchema(); } if (!isset($this->widgetSchema['rt_shop_products_list'])) { // Widget has been unset return; } if (null === $con) { $con = $this->getConnection(); } Doctrine_Query::create()->from('rtShopProductToCategory ptc')->andWhere('ptc.category_id = ?', $this->object->id)->delete()->execute(); $values = $this->getValue('rt_shop_products_list'); if (!is_array($values)) { $values = array(); } if (count($values)) { $i = 0; foreach ($values as $v) { $rt_product_to_category = new rtShopProductToCategory(); $rt_product_to_category->setCategoryId($this->object->id); $rt_product_to_category->setProductId($v); $rt_product_to_category->setPosition($i); $rt_product_to_category->save(); $i++; } } }
$cat2->setRgt(3); $cat2->setLevel(1); $cat2->save(); } catch (Exception $e) { throw new sfException('Categories could not be added! Please check.'); } // Product to category try { $prod1tocat2 = new rtShopProductToCategory(); $prod1tocat2->setProductId($prod1->getId()); $prod1tocat2->setCategoryId($cat2->getId()); $prod1tocat2->save(); $prod2tocat2 = new rtShopProductToCategory(); $prod2tocat2->setProductId($prod2->getId()); $prod2tocat2->setCategoryId($cat2->getId()); $prod2tocat2->save(); } catch (Exception $e) { throw new sfException('Products could not be added to categories! Please check.'); } // Attributes try { $att1 = new rtShopAttribute(); $att1->setTitle('Attribute A'); $att1->save(); $att2 = new rtShopAttribute(); $att2->setTitle('Attribute B'); $att2->save(); } catch (Exception $e) { throw new sfException('Attributes could not be added! Please check.'); } // Product to attribute
$prod4tocat2 = new rtShopProductToCategory(); $prod4tocat2->setProductId($prod4->getId()); $prod4tocat2->setCategoryId($cat2->getId()); $prod4tocat2->save(); $prod5tocat2 = new rtShopProductToCategory(); $prod5tocat2->setProductId($prod5->getId()); $prod5tocat2->setCategoryId($cat2->getId()); $prod5tocat2->save(); $prod6tocat2 = new rtShopProductToCategory(); $prod6tocat2->setProductId($prod6->getId()); $prod6tocat2->setCategoryId($cat2->getId()); $prod6tocat2->save(); $prod7tocat2 = new rtShopProductToCategory(); $prod7tocat2->setProductId($prod7->getId()); $prod7tocat2->setCategoryId($cat2->getId()); $prod7tocat2->save(); } catch (Exception $e) { throw new sfException('Products could not be added to categories! Please check.'); } try { $att1 = new rtShopAttribute(); $att1->setTitle('Attribute A'); $att1->save(); $att2 = new rtShopAttribute(); $att2->setTitle('Attribute B'); $att2->save(); } catch (Exception $e) { throw new sfException('Attributes could not be added! Please check.'); } try { $prod1toatt1 = new rtShopProductToAttribute();
} catch (Exception $e) { throw new sfException('Categories could not be added! Please check.'); } try { $prod1tocat2 = new rtShopProductToCategory(); $prod1tocat2->setProductId($prod1->getId()); $prod1tocat2->setCategoryId($cat2->getId()); $prod1tocat2->save(); $prod2tocat2 = new rtShopProductToCategory(); $prod2tocat2->setProductId($prod2->getId()); $prod2tocat2->setCategoryId($cat2->getId()); $prod2tocat2->save(); $prod3tocat2 = new rtShopProductToCategory(); $prod3tocat2->setProductId($prod3->getId()); $prod3tocat2->setCategoryId($cat2->getId()); $prod3tocat2->save(); } catch (Exception $e) { throw new sfException('Products could not be added to categories! Please check.'); } try { $att1 = new rtShopAttribute(); $att1->setTitle('Attribute A'); $att1->save(); $att2 = new rtShopAttribute(); $att2->setTitle('Attribute B'); $att2->save(); } catch (Exception $e) { throw new sfException('Attributes could not be added! Please check.'); } try { $prod1toatt1 = new rtShopProductToAttribute();