public function testClearMediaAttribute() { /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product'); $product->setData(['image' => 'test1', 'small_image' => 'test2', 'thumbnail' => 'test3']); $this->assertNotEmpty($product->getData('image')); $this->_model->clearMediaAttribute($product, 'image'); $this->assertNull($product->getData('image')); $this->assertNotEmpty($product->getData('small_image')); $this->assertNotEmpty($product->getData('thumbnail')); $this->_model->clearMediaAttribute($product, ['small_image', 'thumbnail']); $this->assertNull($product->getData('small_image')); $this->assertNull($product->getData('thumbnail')); }
public function testClearMediaAttribute() { /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product'); $product->setData(array('test_media1' => 'test1', 'test_media2' => 'test2', 'test_media3' => 'test3')); $product->setMediaAttributes(array('test_media1', 'test_media2', 'test_media3')); $this->assertNotEmpty($product->getData('test_media1')); $this->_model->clearMediaAttribute($product, 'test_media1'); $this->assertNull($product->getData('test_media1')); $this->assertNotEmpty($product->getData('test_media2')); $this->assertNotEmpty($product->getData('test_media3')); $this->_model->clearMediaAttribute($product, array('test_media2', 'test_media3')); $this->assertNull($product->getData('test_media2')); $this->assertNull($product->getData('test_media3')); }
/** * {@inheritdoc} */ public function clearMediaAttribute(\Magento\Catalog\Model\Product $product, $mediaAttribute) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'clearMediaAttribute'); if (!$pluginInfo) { return parent::clearMediaAttribute($product, $mediaAttribute); } else { return $this->___callPlugins('clearMediaAttribute', func_get_args(), $pluginInfo); } }