/** * @param $fixtureId * @param bool $save * @throws \Magefix\Exceptions\ProductMediaGalleryImageNotFound */ protected function _addMediaGalleryImage($fixtureId, $save = true) { if ($this->_hasMediaGallery()) { MagentoStoreScope::setAdminStoreScope(); $product = $this->_getMageModel()->load($fixtureId); if ($product) { MediaGalleryImage::save($product, $this->_getMediaGallery(), $save); } MagentoStoreScope::setCurrentStoreScope(); } }
/** * @return mixed * @throws \Exception */ protected function _saveFixture() { MagentoStoreScope::setAdminStoreScope(); $this->_getMageModel()->setCanSaveCustomOptions(true); $this->_getMageModel()->setCanSaveBundleSelections(true); $this->_getMageModel()->setAffectBundleProductSelections(true); Mage::register('product', $this->_getMageModel()); $this->_buildBundleProductsFixtures(); $this->_setBundleOptions(); $this->_getMageModel()->setBundleOptionsData($this->_bundleOptions); $this->_setBundleSelections(); $this->_getMageModel()->setBundleSelectionsData($this->_bundleSelections); $this->_addMediaGalleryImage($this->_getMageModel()->getId(), false); $fixture = $this->_getMageModel()->save(); MagentoStoreScope::setCurrentStoreScope(); return $fixture->getId(); }
/** * @param MagentoModel $mageModel * @param $data * @return mixed * @throws \Exception */ protected function _saveFixtureWithModelAndData(MagentoModel $mageModel, $data) { MagentoStoreScope::setAdminStoreScope(); $mageModel->setData($data); $mageModel->save(); MagentoStoreScope::setCurrentStoreScope(); return $mageModel->getId(); }
/** * @param string feature|scenario|step $hook */ protected static function _cleanupFixtureByHook($hook) { $registry = self::_getBuilderRegistry(); $registryIterator = new RegistryIterator($registry); MagentoStoreScope::setAdminStoreScope(); $registryIterator->iterateByHook($hook); MagentoStoreScope::setCurrentStoreScope(); }