コード例 #1
0
 public function testAfterAfterSaveNotSwatchAttribute()
 {
     $this->abstractSource->expects($this->once())->method('getAllOptions')->willReturn($this->allOptions);
     $this->swatch->expects($this->once())->method('getId')->willReturn(1);
     $this->swatch->expects($this->once())->method('save');
     $this->swatch->expects($this->once())->method('isDeleted')->with(false);
     $this->swatch->expects($this->exactly(2))->method('setData')->withConsecutive(['type', Swatch::SWATCH_TYPE_TEXTUAL], ['value', null]);
     $this->collection->expects($this->exactly(2))->method('addFieldToFilter')->withConsecutive(['option_id', self::OPTION_ID], ['store_id', self::OPTION_ID])->willReturnSelf();
     $this->collection->expects($this->once())->method('getFirstItem')->willReturn($this->swatch);
     $this->collectionFactory->expects($this->once())->method('create')->willReturn($this->collection);
     $this->attribute->expects($this->at(0))->method('getData')->with('option')->willReturn($this->optionIds);
     $this->attribute->expects($this->at(1))->method('getSource')->willReturn($this->abstractSource);
     $this->attribute->expects($this->at(2))->method('getData')->with('swatch/value')->willReturn([self::STORE_ID => [self::OPTION_ID => null]]);
     $this->attribute->expects($this->at(3))->method('getData')->with('option/delete/' . self::OPTION_ID)->willReturn(false);
     $this->swatchHelper->expects($this->exactly(2))->method('isSwatchAttribute')->with($this->attribute)->will($this->onConsecutiveCalls(true, false));
     $this->swatchHelper->expects($this->once())->method('isVisualSwatch')->with($this->attribute)->willReturn(false);
     $this->swatchHelper->expects($this->once())->method('isTextSwatch')->with($this->attribute)->willReturn(true);
     $this->eavAttribute->afterAfterSave($this->attribute);
 }
コード例 #2
0
 /**
  * Save operation
  *
  * @param Swatch $swatch
  * @param integer $optionId
  * @param integer $storeId
  * @param integer $type
  * @param string $value
  * @return void
  */
 protected function saveSwatchData($swatch, $optionId, $storeId, $type, $value)
 {
     if ($this->isSwatchExists) {
         $swatch->setData('type', $type);
         $swatch->setData('value', $value);
     } else {
         $swatch->setData('option_id', $optionId);
         $swatch->setData('store_id', $storeId);
         $swatch->setData('type', $type);
         $swatch->setData('value', $value);
     }
     $swatch->save();
 }