public function getProducts() { $arrProducts = AROShopProduct::finder()->findMany('id IN (SELECT shop_product_id FROM shop_products_in_categories WHERE shop_category_id = ?)', $this->id); foreach ($arrProducts as $prod) { $prod->init($this); } return $arrProducts; }
<?php require_once 'cfg_admin.php'; require_once 'cfg_complete.php'; logincheck(); $objShop = AROImplementation::loadImplementationByID($_GET['id']); if (isset($_GET['del'])) { $db->delete('shop_products', 'shop_implementation_id = ' . $objShop->implementation_id . ' AND id = ' . $_GET['del']); header('Location: ?id=' . $objShop->id); exit; } echo '<h1>Editing shop: ' . $objShop->title . ' | Products</h1>'; $arrProducts = AROShopProduct::finder()->findMany('shop_implementation_id = ?', $objShop->implementation_id); ?> <p><a href="properties.php?id=<?php echo $objShop->id; ?> ">Properties</a> | <a href="categories.php?id=<?php echo $objShop->id; ?> ">Categories</a> | <a href="edit.php?id=<?php echo $objShop->id; ?> ">Products</a></p> <?php echo '<table border="0" cellpadding="5" cellspacing="0">'; echo '<tr><td colspan="2" align="center"><a href="new_product.php?id=' . $objShop->id . '">New product</a></td></tr>'; foreach ($arrProducts as $prod) { $prod->init($objShop); echo '<tr><td><a href="' . $prod->image_1 . '"><img src="' . $prod->image_1 . '" width="30" height="30" /></a></td><td><a href="edit_product.php?id=' . $objShop->id . '&prod=' . $prod->id . '">' . $prod->title . '</a></td><td><a href="?id=' . $objShop->id . '&del=' . $prod->id . '">x</a></td></tr>'; }
public function getProducts() { $arrProducts = AROShopProduct::finder()->findMany('shop_implementation_id = ?', $this->implementation_id); foreach ($arrProducts as $prod) { $prod->init($this); } return $arrProducts; }
<?php require_once 'cfg_admin.php'; logincheck(); $objShop = AROImplementation::loadImplementationByID($_GET['id']); $objProd = AROShopProduct::finder()->findOne('id = ? AND shop_implementation_id = ?', $_GET['prod'], $objShop->implementation_id)->init($objShop); if (isset($_POST['title'], $_POST['content_1'])) { $arrUpdate = array('title' => $_POST['title'], 'content_1' => $_POST['content_1']); foreach (array('1') as $n) { $szColName = 'image_' . $n; if (!empty($_FILES[$szColName]) && 0 == $_FILES[$szColName]['error']) { $szExt = strtolower(substr(strrchr($_FILES[$szColName]['name'], '.'), 1)); if (in_array($szExt, array('jpg', 'jpeg', 'gif', 'bmp', 'png'))) { if ($u = move_uploaded_file($_FILES[$szColName]['tmp_name'], PROJECT_PUBLIC_RESOURCES . '/shop_product_' . $objProd->id . '_' . $n . '.' . $szExt)) { $arrUpdate[$szColName] = $szExt; } } } } $db->update('shop_products', $arrUpdate, 'id = ' . $objProd->id); $db->delete('shop_products_in_categories', 'shop_product_id = ' . $objProd->id); foreach (isset($_POST['cats']) ? (array) $_POST['cats'] : array() as $cat) { $db->insert('shop_products_in_categories', array('shop_product_id' => $objProd->id, 'shop_category_id' => $cat)); } header('Location: edit.php?id=' . $objShop->id); exit; } echo '<h1>Editing shop: ' . $objShop->title . ' | ' . $objProd->title . '</h1>'; $arrSelectedCats = (array) $db->select_fields('shop_products_in_categories', 'shop_category_id,shop_category_id', 'shop_product_id = ' . $objProd->id); ?> <p><a href="product_images.php?id=<?php