Hướng dẫn thay đổi template step by step ppsx

10 323 0
Hướng dẫn thay đổi template step by step ppsx

Đang tải... (xem toàn văn)

Thông tin tài liệu

Hướng dẫn thay đổi template step by step Phần 1 Trải qua thời gian hoạt động, tôi cảm thấy thiếu sót vì bài viết này đã không viết sớm hơn cho các bạn. Việc thay đổi giao diện cho Magento đối với tôi nó rất đơn giản, nhưng với anh chị em mới làm quen lại vô cùng khó khăn. Đây là bài viết hướng dẫn cụ thể nhất, các bạn hãy làm theo hướng dẫn này chắc chắn sẽ thay đổi được template theo yêu cầu của mình. Chú ý: Bài viết này tôi sẽ thay đổi template theo gói default của magento. Tổng quan: Giới thiệu các thư mục trong magento * APP: Thư mục chứa tất cả các file liên quan tới các module, template, các file run hệ thống * Downloader: Thư mục lưu trữ tất cả các module được download về bằng magentoconnect ( Install module online) * Errors: Thư mục chứa file liên quan tới các thông báo lỗi. * Includes: Chèn các file mở rộng khác. * JS: Chứa tất cả các file js của hệ thống * LIB: Chứa các file hệ thống, zend * Media: chứa các file hình ảnh của website. * pkginfor: Thông tin gói sản phẩm * SHELL: các file liên quan tới reindex * skin: chức các file css, javascript, image cho template * VAR: chứa các file liên quan tới cache, export Bước 1: Đặt tên template Để tạo ra 1 bộ template cho mình theo tên mình thích các bạn làm như sau: 1. Copy toàn bộ thư mục default trong base qua thư mục default bên dưới (màu vàng thứ ). 2. Đổi tên thành tên mình thích, giả sử ở đây tôi đổi tên thành magentovietnam 3. Qua thư mục skin và làm tương tự như trên, bạn sẽ thấy kết quả giống trong hình trên Bước 2: Qui định template hiển thị trên website: Các bạn làm như sau: 1. login vào admin 2. Trên menu bạn chọn Hệ thống > Cấu hình > Thiết kế giao diện 3. Nhập tên template vào ô mặc định 4. Chọn Lưu cài đặt Đây là các bước cơ bản trong việc thay đổi template cho magento Hệ thống bái viết này còn nhiều phần, hãy đón đọc các phần tiếp theo. Xem thêm tại đây: http://www.magentovietnam.com/su-dung-magento/401/huong-dan-thay-doi- template-step-by-step-phan-1.html Lấy Tất cả các Category Các hàm tương tác với Category function get_categories(){ ->cac category level 1 $category = Mage::getModel('catalog/category'); $tree = $category->getTreeModel(); $tree->load(); $ids = $tree->getCollection()->getAllIds(); $arr = array(); if ($ids){ foreach ($ids as $id){ $cat = Mage::getModel('catalog/category'); $cat->load($id); array_push($arr, $cat); } } return $arr; } Danh sách các hàm cần thiết của Category 1/ category->getId(); 2/ category->getImageUrl(); 3/ category->getName(); 4/ category->getLevel(); 5/ category->getPosition(); 6/ category->getIsActive(); 7/ $arrChildren = $category->getChildren(); 8/ $category->getDescription(); 9/ $category->getUrl(); 10/ $category->getAllChildren (); -> chuoi cac id, bao gom ca id cua chinh no va id con (ket qua : 2,5,6 voi id=2 la cua chinh no) 11/ $category->getChildren (); chuoi cac id con (ket qua : 5, 6) PRODUCT foreach ($a_product_new_collection as $item) { $product= Mage::getModel('catalog/product')->load($item->getId()); //All function of Product will be get in file : app/code/core/Mage/Catalog/Model/product.php //See some basic function below: $i_product_id = $product->getId(); $s_product_name = $product->getName(); $s_url_img_basic = $product->getImageUrl(); $s_url_img_small = $product->getSmallImageUrl(88, 77); $s_url_img_thum_bnail = $product->getThumbnailUrl(75, 75); $s_description = $product->getDescription(); $f_price = $product->getPrice(); $f_special_price = $product->getSpecialPrice(); $s_type = $product->getTypeId(); $i_state = $product->getStatus(); } Nếu ta them 1 attribute mới cho Product, VD : Size có code là ‘size’ $pr_add= Mage::getModel('catalog/product')->load(18); $name = $pr_add->getName(); //Nếu size là kiểu Dropdown $size = $pr_add->getAttributeText('size'); //Nếu test_note là kiểu Textbox $test_note = $pr_add->getData('test_note'); echo "Test:".$name." $$ ".$size." $$ ".$test_note; Hoac cach dung chung $size = $pr_add->getResource()->getAttribute('size')->getFrontend()- >getValue($pr_add); $test_note = $pr_add->getResource()->getAttribute('test_note')- >getFrontend()->getValue($pr_add); SHOPPING CART $pr_add= Mage::getModel('catalog/product')->load(9); $cart = Mage::getSingleton('checkout/cart'); $cart->addProduct($pr_add, $opt); $cart->save(); $pro_cart = $cart->getItems(); foreach($pro_cart as $_item){ echo "<br/>Test Cart : ".$_item->getName(); } ATTRIBUTE *$model_att = Mage::getModel('eav/entity_attribute'); $att_id = $model_att->getIdByCode( 'catalog_product', 'size' ); $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $att_id); foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){ echo "<br/>Option : "."[value =".$option['value']."] ; [text = ". $option['label']."]"; } //Test Attribute $model_att = Mage::getModel('eav/entity_attribute'); echo "<br/>Attribute "; $att_id = $model_att->getIdByCode( 'catalog_product', 'style' ); $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $att_id); foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){ echo "<br/>Option : "."[value =".$option['value']."] ; [text = ". $option['label']."]"; } echo "<br/>Attribute "; $att_id = $model_att->getIdByCode( 'catalog_product', 'size' ); $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $att_id); foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){ echo "<br/>Option : "."[value =".$option['value']."] ; [text = ". $option['label']."]"; } echo "<br/>Attribute "; $att_id = $model_att->getIdByCode( 'catalog_product', 'color' ); $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $att_id); foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){ echo "<br/>Option : "."[value =".$option['value']."] ; [text = ". $option['label']."]"; } //Test Get All Product by Attribute $att_code = 'style'; $id_option_att = 20; $products = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToFilter($att_code, $id_option_att) ->addAttributeToFilter('size', 18) ->addAttributeToFilter('color', 25); echo "<br/>Test product "; foreach ($products as $item) { $pr= Mage::getModel('catalog/product')->load($item- >getId()); echo "<br/>Product : ".$pr->getId(); } // GET IMGAGES TO SHOW OR HIDE $urlImg0 = $this->getSkinUrl("images/block_show_image0.png"); $urlImg1 = $this->getSkinUrl('images/block_show_image1.png'); $urlImg2 = $this->getSkinUrl('images/block_show_image2.png'); $urlImg3 = $this->getSkinUrl('images/block_show_image3.png'); $urlImg4 = $this->getSkinUrl('images/block_show_image4.png'); //Check My Cart Has Product $o_my_cart = Mage::getSingleton('checkout/cart'); $a_product_my_cart = $o_my_cart->getItems(); $i_count_my_cate = count($a_product_my_cart); $s_count_my_cart = $i_count_my_cate; if($s_count_my_cart < 9){ $s_count_my_cart = '0'.$s_count_my_cart; } $s_class_my_cart = 'list_link_bottm243'; $s_class_padding = 'padding-left100'; if($i_count_my_cate > 0 ) { $s_class_my_cart = 'list_link_bottm122'; $s_class_padding = 'padding-left90'; } Add To Cart with quantity default is 1 http://s1.ruby.com/checkout/cart/add/product/$id_product/?___SID=U Add To Cart with quantity is $qty http://s1.ruby.com/checkout/cart/add?product=$id_product&qty=$qty Insert into Table out of magento   !"! ! ! #$ %&'()*+*, /-0/00***#$ !! "!1 22 ! !3 4  3#56 7!! "!3 8 3#$ !! "!56 !!"!#$ !! "!56 #$ !! "!5699#$ Insert into Table out of magento Insert into Table other ways 8 1 22 ! !3 4  3#56 7!! "!3 8 3#$ 8 56 ("insert into tablename values ('aaa','bbb','ccc')"); User Login : Mage::getSingleton('customer/session') • Mage::getSingleton('customer/session')->isLoggedIn() => ‘’ (not login) or 1 (login)] • • $session = Mage::getSingleton('customer/session'); • $customer = $session->getCustomer(); • $cust_id = $customer->getId(); • $cust_name = $customer->getName(); . Hướng dẫn thay đổi template step by step Phần 1 Trải qua thời gian hoạt động, tôi cảm thấy thiếu sót vì bài viết này đã không viết sớm hơn cho các bạn. Việc thay đổi giao diện. khăn. Đây là bài viết hướng dẫn cụ thể nhất, các bạn hãy làm theo hướng dẫn này chắc chắn sẽ thay đổi được template theo yêu cầu của mình. Chú ý: Bài viết này tôi sẽ thay đổi template theo gói default. theo. Xem thêm tại đây: http://www.magentovietnam.com/su-dung-magento/401/huong-dan -thay- doi- template- step- by -step- phan-1.html Lấy Tất cả các Category Các hàm tương tác với Category function

Ngày đăng: 14/08/2014, 05:21

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan