Development

Create Drupal commerce order programatically


Drupal commerce had become the major implementation of all-in-one ecommerce solution, from ubercart.

Ubercart was long from Drupal5.x era
To work with entities that build-in Drupal7, and also make Drupal's commerce solution brand-less, Drupal commerce was born.

Drupal feeds module: FeedsProcessor with ubercart Order


使用者情境:批量使用 CSV 匯入 ubercart 訂單

Feeds 模組已經有一個 CSV 格式讀取 parser,又有批量 batch 支持,能處理大檔案 CSV ,Feeds 的代碼也有很多使用的經驗,而且最重要的是,模組自己已經有四種內容可以匯入:(nodes, users, terms, feednode?),有更高的機會支持其他內容 (ubercart orders)

Drupal feeds module: FeedsProcessor with ubercart Order


Use case: need to import batch ubercart orders from a CSV

Feeds module have a CSV parser already, have batch process build in, can process a large CSV already, and proven code. The most import, there are already 4 type of content that can be import (nodes, users, terms, feednode?), so likely there are other ways to import new content as well.

Web dev's dilemma: integration resopsibility

-
Free tags: 

Situational question: AJAX POST to /user/create

Frontend HTML dev should find out URI /user/create and put inside JS, or;
Backend dev should put that in after completing user controller?

This grey area responsibility keeps popping up during the day
In some complex application with AJAX GET, POST, Facebook API with multiple end point URI
the communication effort is near to the development effort itself

網頁工程師們的兩難:問中間灰色地帶的責任

-
Free tags: 

情境題:AJAX POST 到 /user/create
究竟是

前端HTML工程師要找出路徑 /user/create 放到 JS
還是後端工程師在完成 user controller 之後負責修改 JS 檔?

這個中間灰色地帶的責任問題一直困擾我們的工作
在某些複雜的 AJAX GET, POST, Facebook API 等多個溝通點的情況之下
中間 integration 需要的溝通量有時差不多和開發的時間相等

前端不想打開 controllers 找出 controller 的 method
後端不想看 JS 的 jquery object, success callback 還可能需要 handle HTML
但在這個兩難式中間
始終有一個人需要完成灰色的工作

我們需要一個有效率而又相對公平的方法
還是這就是工程師們必要的溝通?
那遙距的團隊要如何解決這個問題?

Custom feeds tamper plugin

feeds tamper module can map multiple columns inside a CSV to the same field as multiple value
But there is a constraint, each field can only "rewrite" once
For example, convert
abc.jpg
to
sites/default/files/abc.jpg
and then multiple them into
sites/default/files/abc.jpg,sites/default/files/def.jpg
Two rewrite is needed in this case
There is no solution from feeds tamper module, you can only use a full path inside the CSV to skip the first rewrtie

客製自定義 feeds tamper plugin

feeds tamper 是一個可以將多個 CSV column map 到同一個多值欄位 (multiple value) 的 module
但問題是使用 "rewrite" 只可以在一個 column 使用
例如要將:
abc.jpg
變為
sites/default/files/abc.jpg
再變為多值
sites/default/files/abc.jpg,sites/default/files/def.jpg
就需要在 image 欄位使用兩次 rewrite
feeds tamper 無辦法解決,只可以在 CSV 上直接使用 full path

但把心一橫,自己寫一個對應 list 的 prefixer 都不是太難

abc.jpg,def.jpg
變為
sites/default/files/abc.jpg,sites/default/files/def.jpg
就只需要一次 rewrite 了

Hong Kong Economic Journal Forum revamp

Snapshot: 

It has been a while since my last post on this blog
Since we just have this project finished, and slowing moving to maintenance mode
This will be a great time to write something about the porject, before I forget everything

信報論壇 revamp

Snapshot: 

都有一段時間忙得要死,沒有更新這個 blog 了
這次的 project 總算順利完成,穩定進入維護階段的同時
花點時間寫一寫這次使用 Drupal 的經驗好了

這個在三月中開始版面設計的網站,當然是使用 Drupal7 開發
結構上不算太複雜,只有首頁,文章內頁,用戶頁,「著名博主」頁
但因為用戶可以自行編寫文章,node edit form 都需要使用客製化的 theme
而且那個 form 需要一定程度的簡化,令一般使用者可以比較容易上手

在網站也使用了 responsive web design 的版面設計
令手機的使用者可以使用一個比較簡單的版面
但 js based 的 responsive 有反應慢,需要等待 js 執行的問題
有機會再和大家分享這方面的心得

Drupal Migrate user pictures 的小小心得

-
Free tags: 

(Migrate 2.5, D7):

  • 建立一個 UserPictureMigration class (你會看到 file_managed table 有新增行數)
  • 在 UserMigration class 中的 prepare(), 用 $this->handleSourceMigration('UserPicture', $row->uid);指定 UserPictureMigration 中的 fid
  • 使用正常的用戶頭像上載的話 file_usage table 會新增紀錄。你可以自己在 complete() 和 completeRollback() 手動補上

又花了兩日的時間:
$this->addFieldMapping('picture')->defaultValue() 傳入 int

public function prepareRow() 會顯示路徑, 但唯讀
最後在
public function prepare() 傳入 fid

Pages

Google