$cat2->setRootId(1); $cat2->setLft(2); $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.');
/** * Return all related products, ordered and published. * * @param rtShopProduct $rt_shop_product * @param Doctrine_Query $query * @return Doctrine_Collection */ public function addRelatedProductQuery(rtShopProduct $rt_shop_product, Doctrine_Query $query = null) { $query = $this->addPublishedQuery($query); $query->leftJoin('page.rtShopProducts related')->leftJoin('page.rtShopProductToProduct link')->orderBy('link.position ASC')->andWhere('link.product_id = ?', $rt_shop_product->getId()); return $query; }
$prod3tocat2->setCategoryId($cat2->getId()); $prod3tocat2->save(); $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.'); }
$cat2->setLevel(1); $cat2->save(); } 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.'); }