src/Extension/ProductControllerFeaturesExtension.php
/**
     * Override features list with grouping.
     */
Override features list with grouping.
Override features list with grouping .
public function GroupedFeatures($showungrouped = false)
    {
        $features = $this->owner->Features()
            ->innerJoin("SilverShop_Feature","SilverShop_Feature.ID = SilverShop_ProductFeatureValue.FeatureID");
        $featuresids = $features->getIDList();
        $sortByGroup = Config::inst()->get(Feature::class, 'sort_features_by_group');
        $groups = FeatureGroup::get()
            ->innerJoin("SilverShop_Feature","SilverShop_Feature.GroupID = SilverShop_FeatureGroup.ID")
            ->innerJoin("SilverShop_ProductFeatureValue","SilverShop_Feature.ID = SilverShop_ProductFeatureValue.FeatureID")
            ->where("SilverShop_ProductFeatureValue.ID IN (" . implode(',',$featuresids) .")" );
        if( $sortByGroup ){
            $groups = $groups->Sort('Title ASC');
        }
        $groupids = $groups->getIDList();
        $result = new ArrayList();
        if(!empty($groupids)){
            foreach($groupids as $groupid) {
                $group = FeatureGroup::get()->byID($groupid);
                if( $sortByGroup ){
                    $children = $features->filter("GroupID", $groupid)->sort("\"SilverShop_Feature\".\"Sort\"");
                } else {
                    $children = $features->filter("GroupID", $groupid);
                }
                $result->push(new ArrayData(
                    [
                        'Group' => $group,
                        'Children' => $children
                    ]
                ));
            }
            if( $showungrouped ) {
                $ungrouped = $features->filter("GroupID:not", $groupids);
                if ($ungrouped->exists() && $showungrouped) {
                    $result->push(new ArrayData(array(
                        'Children' => $ungrouped
                    )));
                }
            }
        }
        return $result;
    }
public function GroupedFeatures ( $ showungrouped = false ) { $ features = $ this -> owner -> Features ( ) -> innerJoin ( " SilverShop_Feature " , " SilverShop_Feature.ID = SilverShop_ProductFeatureValue.FeatureID " ) ; $ featuresids = $ features -> getIDList ( ) ; $ sortByGroup = Config :: inst ( ) -> get ( Feature :: class , 'sort_features_by_group' ) ; $ groups = FeatureGroup :: get ( ) -> innerJoin ( " SilverShop_Feature " , " SilverShop_Feature.GroupID = SilverShop_FeatureGroup.ID " ) -> innerJoin ( " SilverShop_ProductFeatureValue " , " SilverShop_Feature.ID = SilverShop_ProductFeatureValue.FeatureID " ) -> where ( " SilverShop_ProductFeatureValue.ID IN ( " . implode ( ',' , $ featuresids ) . " ) " ) ; if ( $ sortByGroup ) { $ groups = $ groups -> Sort ( 'Title ASC' ) ; } $ groupids = $ groups -> getIDList ( ) ; $ result = new ArrayList ( ) ; if ( ! empty ( $ groupids ) ) { foreach ( $ groupids as $ groupid ) { $ group = FeatureGroup :: get ( ) -> byID ( $ groupid ) ; if ( $ sortByGroup ) { $ children = $ features -> filter ( " GroupID " , $ groupid ) -> sort ( " \" SilverShop_Feature \" . \" Sort \" " ) ; } else { $ children = $ features -> filter ( " GroupID " , $ groupid ) ; } $ result -> push ( new ArrayData ( [ 'Group' => $ group , 'Children' => $ children ] ) ) ; } if ( $ showungrouped ) { $ ungrouped = $ features -> filter ( " GroupID:not " , $ groupids ) ; if ( $ ungrouped -> exists ( ) && $ showungrouped ) { $ result -> push ( new ArrayData ( array ( 'Children' => $ ungrouped ) ) ) ; } } } return $ result ; }
Override features list with grouping.
Override features list with grouping .
// check sorting option //figure out feature groups //pack existing features into seperate lists // sort on order within group // sort on order at product level, default