2
としてはタイトルに言ったカテゴリID与えられたすべての子供たちにカテゴリを検索:Magentoの、私は私のカスタム関数を使用してこのようなものをやろうとしている
public function retrieveAllChilds($id = null, $childs = null){
$childIdsArray = is_null($childs) ? array() : $childs;
$category = is_null($id) ? $this->getCurrentCategory() : $this->getCategoryFromId($id);
if (count($this->getChildrenCategories($id)) > 0) {
$c = count($this->getChildrenCategories($id));
$tmp_array = array();
foreach ($this->getChildrenCategories($id) as $category) {
array_push($tmp_array, $category->getId());
}
$childIdsArray = array_merge($childIdsArray, $tmp_array);
foreach ($this->getChildrenCategories($id) as $category){
$this->retrieveAllChilds($category->getId(), $childIdsArray);
}
}
else{
return array_unique($childIdsArray);
}
return array_unique($childIdsArray);
}
が、停止中かで間違った何かがありますようです終了条件関数は最初の16個の要素を正しく検索します。誰も私を助けることができますか?
ことを除いて、デフォルトでは、それは(だけなので、トップレベル)を再帰的にそれらをフェッチしません。あなたは、正確に正しいです。彼は次のものを使いたいでしょう:$ category-> getResource() - > getChildren($ category、true); –
まさに@DanielSloofです。ちょうど私の答えにそれを加えました。 – Simon
tnxみんな。私は同様の方法でそれをやった – Luke