ブロック編集のカテゴリブロックでも、カテゴリ一覧が取得されているので、
それに近づければうまくいくかなという発想で、ゴリ押しでやってみたら出来ました。
正直よくわからずやっているので、たぶん褒められた方法ではないと思いますが・・・。
今のところ思った通りの結果は得られていますが、問題点などありましたら教えてください。
.data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_SearchProducts.php の70行目付近に以下のコードを追加。
(LC_Page_FrontParts_Bloc_Category.phpからコピっただけ)
$this->lfGetCatTree($this->category_id, true, $this);
同じく.data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_SearchProducts.php の88行目付近に以下のコードを追加。
(LC_Page_FrontParts_Bloc_Category.phpからコピっただけ)
// カテゴリツリーの取得
function lfGetCatTree($arrParent_category_id, $count_check = false) {
$objQuery = new SC_Query();
$objDb = new SC_Helper_DB_Ex();
$col = "*";
$from = "dtb_category left join dtb_category_total_count using (category_id)";
// 登録商品数のチェック
if($count_check) {
$where = "del_flg = 0 AND product_count > 0";
} else {
$where = "del_flg = 0";
}
$objQuery->setOption("ORDER BY rank DESC");
$arrRet = $objQuery->select($col, $from, $where);
foreach ($arrParent_category_id as $category_id) {
$arrParentID = $objDb->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id);
$arrBrothersID = SC_Utils_Ex::sfGetBrothersArray($arrRet, 'parent_category_id', 'category_id', $arrParentID);
$arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $category_id);
$this->root_parent_id[] = $arrParentID[0];
$arrDispID = array_merge($arrBrothersID, $arrChildrenID);
foreach($arrRet as $key => $array) {
foreach($arrDispID as $val) {
if($array['category_id'] == $val) {
$arrRet[$key]['display'] = 1;
break;
}
}
}
}
$this->arrTree = $arrRet;
}
.data/Smarty/templates/default/bloc/search_products.tpl の適当な場所に以下のコードを追加。
(自分で適当に書きました)
<style type="text/css">
select option.level1 { background-color:#999; color:#fff; }
select option.level2 { background-color:#f6f6f6; }
select option.level3 { background-color:#ff0000; }
select option.level4 { background-color:#00ff00; }
select option.level5 { background-color:#0000ff; }
</style>
<!--{section name=cnt loop=$arrTree}-->
<option label="<!--{$arrTree[cnt].category_name}-->" value="<!--{$arrTree[cnt].category_id}-->" class="level<!--{$arrTree[cnt].level}-->"<!--{if $smarty.get.category_id == $arrTree[cnt].category_id}--> selected<!--{/if}-->><!--{$arrTree[cnt].category_name}--></option>
<!--{/section}-->