/** * getDetail - Phương thức dùng để lấy dữ liệu */ public function getDetail($product_id = null) { Yii::import('application.modules.products.models.ProductItem'); $data = array(); if ($product_id) { $data = ProductItem::model()->findByPk($product_id); } return $data; }
public function action_index($category_slug = '') { if ($category_slug != '') { $category = ProductCategory::bll()->findOneBy('slug', $category_slug); if (!$category) { //category not found } $this->template->title = __($category['name'] . " | Sản phẩm |"); $total_items = ProductItem::bll()->getItemsCountByCat_Front_Listing($category['id']); $pagging = Pagination::factory(array('total_items' => $total_items, 'items_per_page' => 12)); $items = ProductItem::bll()->getItemsByCat_Front_Listing($category['id'], $pagging->offset, $pagging->items_per_page); } $data['category'] = $category; $data['items'] = $items; $data['page_link'] = $pagging->render(); $this->template->content = View::factory('/front/product/item/list', $data); }
public function actionResetImage() { $uploadPath = YiiBase::getPathOfAlias('webroot') . '/files/products'; @set_time_limit(0); $items = ProductItem::model()->findAll(); foreach ($items as $item) { $thumbsPath = $uploadPath; $filename = $item->image; @unlink($thumbsPath . '/thumb_' . $filename); // thumbnails image Yii::import("ext.EPhpThumb.EPhpThumb"); $thumb = new EPhpThumb(); $thumb->init(); //this is needed $thumb->create($uploadPath . '/' . $filename)->adaptiveResize(Yii::app()->getModule('products')->widthThumb, Yii::app()->getModule('products')->heightThumb)->save($thumbsPath . '/thumb_' . $filename); } echo 'Done!'; }
echo $item['name']; ?> </strong> <div class="product_image"> <a href="<?php echo Route::url('product_detail', array('category_slug' => $category['slug'], 'product_slug' => $item['slug'])); ?> "> <img src="<?php echo $item['thumb_image']; ?> " width="175" height="120" alt="" border="0"/> </a> </div> <div> <span style="display: block; width: 115px; line-height: 24px; float: left; font-weight: bold; color:#D8540D;"> <?php echo ProductItem::format_price($item['price']); ?> </span> <span style="display: block; width: 95px; float: left;"> <a href="<?php echo Route::url('product_detail', array('category_slug' => $category['slug'], 'product_slug' => $item['slug'])); ?> " class="view_detail_btn"> Xem chi tiết </a> </span> <span> </span> </div> </div>
/** * @param int $Id * @param float $QuantityCancelled * @param string $Description * @param string $ShortDescription * @param string $Warehouse * @param string $Bin * @param string $QuoteNumber * @param string $QuoteName * @param ArrayOfComponent $BundleComponents */ public function __construct($Id = null, $QuantityCancelled = null, $Description = null, $ShortDescription = null, $Warehouse = null, $Bin = null, $QuoteNumber = null, $QuoteName = null, $BundleComponents = null) { parent::__construct($Id, $QuantityCancelled, $Description, $ShortDescription, $Warehouse, $Bin, $QuoteNumber, $QuoteName, $BundleComponents); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = ProductItem::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function action_delete($product_id = 0) { $this->auto_render = false; $ok = false; $cat_id = 0; if (intval($product_id) > 0) { $item = ProductItem::bll()->find($product_id); if ($item) { $cat_id = $item->cat_id; $item->delete(); $ok = true; } } if ($ok) { Message::success('Xóa sản phẩm thành công!'); } else { Message::error('Xóa sản phẩm không thành công!'); } if ($cat_id != 0) { Request::instance()->redirect('/admin/product/by_cat/' . $cat_id); } else { Request::instance()->redirect('/admin/productcategory/index'); } }