/** * {@inheritdoc} */ public function afterLoad($object) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'afterLoad'); if (!$pluginInfo) { return parent::afterLoad($object); } else { return $this->___callPlugins('afterLoad', func_get_args(), $pluginInfo); } }
public function testAfterSaveAndAfterLoad() { $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product'); $product->setId(1); $product->setData('media_gallery', ['images' => ['image' => ['file' => 'magento_image.jpg']]]); $this->_model->afterSave($product); $this->assertEmpty($product->getData('media_gallery/images/0/value_id')); $this->_model->afterLoad($product); $this->assertNotEmpty($product->getData('media_gallery/images/0/value_id')); }
/** * @dataProvider afterLoadDataProvider * @param array $image */ public function testAfterLoad($image) { $attributeCode = 'attr_code'; $attribute = $this->getMock('Magento\\Eav\\Model\\Entity\\Attribute', ['getAttributeCode', '__wakeup'], [], '', false); $attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attributeCode)); $this->resourceModel->expects($this->any())->method('loadGallery')->will($this->returnValue([$image])); $this->model->setAttribute($attribute); $this->model->afterLoad($this->dataObject); $this->assertEquals([$image], $this->dataObject->getAttrCode('images')); }