Lập trình components carts - quản lý sản phẩm - update phần 7

Đây là một component hoàn chỉnh với chức năng, thêm xóa sửa sản phẩm, show sản phẩm và cho phép đặt hàng, kiểm tra đơn hàng.....
Vì là dạng nâng cao nên được chia thành nhiều phần, mỗi phần tiếp theo sẽ được cập nhật ngay tài bài viết này.
File thực hành: http://www.mediafire.com/?kl4067yrb7pco9m




Phần 1: Back-end MVC


Phần 2: Xây dựng form views products


Phần 3: Các tác vụ controller, models, xử lý introtext và fulltext


Phần 4: Sử dụng section và category từ com_content và tooltip image


Phần 5: Front-end tooltip kết hợp Jquery


Phần 6: Sử dụng Ajax để tạo giỏ hàng


Phần 7: Hiển thị giỏ hàng, cập nhật số lượng và xóa sản phẩm

25 comments:

  1. E làm giống a mà file default ko hiện sản phẩm gì hết, trong khi đó CSDL đã có. E nghi lỗi nằm trong 2 file này:
    FIle model:
    function getList($conf){
    $sql = "SELECT p.*,u.username AS editor FROM #__carts_products AS p
    LEFT Join #__users AS u ON u.id=h.checked_out
    ORDER BY ".$conf['order']." ".$conf['order_Dir'] ;
    return $this->_getList($sql,$conf['limitstart'],$conf['limit']);
    }

    function getTotal(){

    $this->_db->setQuery("SELECT count(id) FROM #__carts_products");
    return $this->_db->loadResult();
    }
    Fiel view.html.php
    function getList(){
    global $mainframe;
    $conf['order'] = $mainframe->getUserStateFromRequest('com_carts.products.filter_order','filter_order','p.id','string');
    $conf['order_Dir'] = $mainframe->getUserStateFromRequest('com_carts.products.filter_order_Dir','filter_order_Dir','ASC','string');
    $conf['limitstart'] = $mainframe->getUserStateFromRequest('com_carts.products.limitstart','limitstart',0,'int');
    $conf['limit'] = $mainframe->getUserStateFromRequest('com_carts.products.limit','limit',$mainframe->getCfg('list_limit'),'int');
    $model = & $this->getModel();
    $list = $model->getList($conf);
    $this->rows=$list;

    jimport('joomla.html.pagination');
    $total = $model->getTotal();
    $pan = new JPagination($total,$conf['limitstart'],$conf['limit']);
    $this->pan=$pan;

    }
    E tìm hoài , thấy giống a hoàn toàn, kể cả fiel default mà nó ko xuất dữ liệu ra. A giúp e vơi

    ReplyDelete
  2. LEFT Join #__users AS u ON u.id=h.checked_out : p.checked_out nha bạn,

    ReplyDelete
    Replies
    1. Sữa rùi a, nó cũng ko hiện lun,nó rơi vào cuối vài 3 của a đó, khi dữ liệu có trong CSD mà ở ngoiaf defaul thì ko hiện. Qua bìa 4 thì a chỉnh gì nó hiện đó, và e có thêm : $this->conf=$conf; để qua layout dùng , nhưng mà cũng bó tay.

      Delete
  3. Bạn đã có hidden filter_order và filter_order_Dir chưa, bạn có thể send code của bạn qua email để tôi kiểm tra xem
    chúc bạn học tốt

    ReplyDelete
  4. Bạn đã có hidden filter_order và filter_order_Dir chưa, bạn có thể send code của bạn qua email để tôi kiểm tra xem
    chúc bạn học tốt

    ReplyDelete
  5. xin lỗi, e là sinh viên hutech lun, nhưng lại ko có mail a. a cho e mail đi, a có thể share source bài này để tiện vừa xem vừa hiểu đc ko a. tránh trường hợp sai ko biết chổ sữa như thế này.

    ReplyDelete
  6. a cho em mail đi a?

    ReplyDelete
    Replies
    1. e đã có 2 trường ẩn trong defaul rùi:
      type="hidden" name="filter_order" value="conf['order']; ?>"
      type="hidden" name="filter_order_Dir" value="conf['odir']; ?>"

      Mà cũng bó tay lun. E mò hoài ko ra , chán thiệt.help me với a ơi.

      Delete
    2. E đã gửi thư, a xem giúp e nhé,Thanks a trước

      Delete
  7. E mất cả ngày vì nó ko hiện dữ liệu lên default,đến giờ e vẫn mò chưa ra,:)). E đã gửi thư, mong a rãnh khi nào thì sữa giúp e sớm, để e đi tiếp và tiếp tục tìm hiểu hết các video clip của a.Vì nó rất hay.^^

    ReplyDelete
    Replies
    1. $conf['order'] = $mainframe->getUserStateFromRequest('com_carts.products.order','filter_order','p.id','string');
      $conf['order_Dir'] = $mainframe->getUserStateFromRequest('com_carts.products.order_Dir','filter_order_Dir','ASC','string');

      Nha bạn
      filter_order và filter_order_Dir nha bạn

      Delete
    2. Chổ đó ban đầu có chữ filter, sau vì nó ko chạy e thử xóa đi, giờ e thêm vào, mà nó vẫn ko chạy a à.E có gửi a source, a sữa chổ đó , test có chạy ko a??
      Mà a có thể share source của a về bài này ko? e bó tay cái source của e rùi, e thấy nó giống a 99% lun mà nó ko hiện dữ liệu trên default, bùn ghê gớm a ơi, giúp e với

      Delete
    3. Chào bạn!
      function getList() trong model bạn sữa lại:
      $sql = "SELECT p.*,u.username,u2.username AS editor FROM #__carts_products AS p
      LEFT Join #__users AS u2 ON u2.id=p.created_by
      LEFT Join #__users AS u ON u.id=p.checked_out
      ORDER BY " . $conf['order'] . " " . $conf['order_Dir'];
      Trong layout default: bạn sữa $this->pan->getrowsOffset($i) thành $this->pan->getRowOffset($i).

      file view.html.php, sữa 2 dòng: $conf['order'] = $mainframe->getUserStateFromRequest('com_carts.products.order', 'filter_order', 'p.id', 'string');
      $conf['order_Dir'] = $mainframe->getUserStateFromRequest('com_carts.products.order_Dir', 'filter_order_Dir', 'ASC', 'string');

      chúc bạn học tốt!

      Delete
  8. code e nó có sữa được ho a?

    ReplyDelete
  9. chưa xem nhưng cũng thank trước ^^

    ReplyDelete
  10. a ơi cho em xin cái com_carts này được không , code e làm theo video a hướng dẫn mà vẫn báo lỗi . cho e xin cái code về e tự ngâm cứu đi

    ReplyDelete
  11. Chào anh. Anh có thể cho em xin cái com này được không. Tại vì em cũng làm theo nhưng đôi khi video mờ quá nên cũng rất hạn chế. Mong anh thông cảm. có thể gửi com này qua mail em cũng được : namtrum999999@gmail.com
    Cảm ơn anh.

    ReplyDelete
  12. Chào Anh Vũ Mai!
    Em làm đến video thứ 3. Khi click vào các button JToolbarHelper (save, edit, cancel) thì bị lỗi này.

    Fatal error: Call to a member function checkin() on a non-object in C:\AppServ\www\joomla\administrator\components\com_carts\models\products.php on line 47

    Mong Anh sửa giúp Em. Em cảm ơn nhiều!

    ReplyDelete
  13. hello please help me

    order panel error

    Warning: Invalid argument supplied for foreach() in /home1/ayhaner/public_html/deryakitabevi.com.tr/administrator/components/com_vshop/views/order/tmpl/edit.php on line 145

    ReplyDelete
    Replies
    1. Hi Kedi!
      You have the old version of vshopping cart (2.5.26), you are should download version 2.6.1 heer http://vshopping.tk/index.php/download-vshopping

      Or you can change the database add a column `params` with varchar(250) on table #__vshop_orderdetail or on the file administrator/components/com_vshop/models/order.php in line 45 you can delete od.params and it works ok!
      Thanks so much!

      Delete
  14. Cái này chưa có phần cuối hả A Vũ Mai.
    Như: Đặt hàng, quản lý khách hàng...
    E đang mong phần cuối. Hihi.
    Cảm ơn A.

    ReplyDelete
  15. anh Vũ Mai ơi cho em hỏi clip 1 anh dùng phần mềm gì thế có thể cho em link download hoặc tên của phần mềm cũng được. Em mới bắt đầu tìm hiểu nên chưa biết gì nhiều mong anh hướng dẫn Thank!

    ReplyDelete

Bạn phải có tài khoản Google (Gmail) hoặc các tài khoản khác (wordpress, openID,...) để có thể comment