コード例 #1
0
ファイル: AbstractEntity.php プロジェクト: aiesh/magento2
 /**
  * Compare attributes
  *
  * @param Attribute $firstAttribute
  * @param Attribute $secondAttribute
  * @return int
  */
 public function attributesCompare($firstAttribute, $secondAttribute)
 {
     $firstSort = $firstAttribute->getSortWeight((int) $this->_sortingSetId);
     $secondSort = $secondAttribute->getSortWeight((int) $this->_sortingSetId);
     if ($firstSort > $secondSort) {
         return 1;
     } elseif ($firstSort < $secondSort) {
         return -1;
     }
     return 0;
 }
コード例 #2
0
 /**
  * @param array|null $sortWeights
  * @param float $expected
  * @dataProvider getSortWeightDataProvider
  */
 public function testGetSortWeight($sortWeights, $expected)
 {
     $setId = 123;
     $this->_model->setAttributeSetInfo([$setId => $sortWeights]);
     $this->assertEquals($expected, $this->_model->getSortWeight($setId));
 }