opencart筆記

[出色的延伸模組網站]
http://isenselabs.com/

後端登入的 ID

$this->user->getId();
在 lib 裡面的 user.php

載入國籍資料
$this->load->model('localisation/country');

取得國家
$this->model_localisation_country->getCountry($country_id);

取得 購物車中的內容
$this->cart->getProducts()

取得客戶資料

$this->load->model('sale/customer');
$cus = $this->model_sale_customer->getCustomer($result[‘customer_id’]);

前端
$this->session->data[‘customer_id’];
    $this->customer->isLogged()
    $this->customer->getId()
    $this->customer->getFirstName()
    $this->customer->getLastName()
    $this->customer->getEmail()
    $this->customer->getTelephone()
    $this->customer->getFax()
    $this->customer->getNewsletter()
    $this->customer->getCustomerGroupId()
    $this->customer->getAddressId()
    $this->customer->getBalance()
    $this->customer->getRewardsPoints()

取得地址
    $address_id = $this->customer->getAddressId();
    $this->load->model('account/address');
    $address = $this->model_account_address->getAddress($address_id);

取得 語言設定

where   language_id = '".$this->config->get('config_language_id')."'

麵包屑機制

            
            $this->data[‘breadcrumbs’] = array();

            $this->data[‘breadcrumbs’][] = array(
                'text'      => $this->language->get('text_home'),
                'href'      => $this->url->link('common/home'),
                'separator' => false
            );
            
            $this->data[‘breadcrumbs’][] = array(
                'text'      => $this->language->get('text_account'),
                'href'      => $this->url->link('account/account', '', 'SSL'),
                'separator' => $this->language->get('text_separator')
            );

取得管理者的名稱

$this->user->getUserName()

opencart 設定

chgrp nobody /home/cart/www/config.php
chgrp nobody /home/cart/www/admin/config.php
chgrp nobody /home/cart/www/system/cache/
chgrp nobody /home/cart/www/system/logs/
chgrp nobody /home/cart/www/image/
chgrp nobody /home/cart/www/image/cache/
chgrp nobody /home/cart/www/image/data/
chgrp nobody /home/cart/www/download/

chmod 775 /home/cart/www/config.php
chmod 775 /home/cart/www/admin/config.php
chmod 775 /home/cart/www/system/cache/
chmod 775 /home/cart/www/system/logs/
chmod 775 /home/cart/www/image/
chmod 775 /home/cart/www/image/cache/
chmod 775 /home/cart/www/image/data/
chmod 775 /home/cart/www/download/

opencart 對於 前端登入的客戶  取用資訊

    $this->customer->isLogged()
    $this->customer->getId()
    $this->customer->getFirstName()
    $this->customer->getLastName()
    $this->customer->getEmail()
    $this->customer->getTelephone()
    $this->customer->getFax()
    $this->customer->getNewsletter()
    $this->customer->getCustomerGroupId()
    $this->customer->getAddressId()
    $this->customer->getBalance()
    $this->customer->getRewardsPoints()
    $address_id = $this->customer->getAddressId();
    $this->load->model('account/address');
    $address = $this->model_account_address->getAddress($address_id);

   opencart 中國與台灣 城市之中文化
  <a href="http://km.orzidea.com/?attachment_id=1487" rel="attachment wp-att-1487">zone</a>

上傳檔名自動修改
檔案   admin/controller/filemanager.php

public function upload()
把 $filename = basename(html_entity_decode($this->request->files[‘image’][‘name’], ENT_QUOTES, 'UTF-8'));
改成
$filename = date("Y-m-d")."_".time().".".$ext;

新增函數
function get_file_extension($file){
     $pos=strpos($file,".");
     $file=substr($file,$pos+1);
     if(strpos($file,".")){
        $file=get_file_extension($file);
     }
     return $file;
  }