/**
  * Fill a gift wrapping model with dummy data so that it can be saved and edited later.
  * @see http://www.magentocommerce.com/boards/viewthread/289906/
  * @param Enterprise_GiftWrapping_Model_Wrapping $wrap gift wrapping model to be autofilled
  * @param string $sku the new gift wrapping's sku
  * @param array $additionalData optional
  * @return Enterprise_GiftWrapping_Model_Wrapping
  */
 protected function _applyDummyData(Enterprise_GiftWrapping_Model_Wrapping $wrap, $sku, array $additionalData = array())
 {
     $wrapData = array_merge($this->_getGiftWrapTplt(), $additionalData);
     $design = isset($wrapData['design']) ? $wrapData['design'] : null;
     $wrapData['design'] = $design ?: "Incomplete gift wrapping: {$sku}";
     $wrapData['eb2c_sku'] = $sku;
     return $wrap->addData($wrapData);
 }
示例#2
0
 /**
  * Save correct website list in giftwrapping
  *
  * @param Enterprise_GiftWrapping_Model_Wrapping $model
  * @return Enterprise_AdminGws_Model_Models
  */
 public function giftWrappingSaveBefore($model)
 {
     if (!$model->isObjectNew()) {
         $roleWebsiteIds = $this->_role->getRelevantWebsiteIds();
         // Website list that was assigned to current giftwrapping previously
         $origWebsiteIds = (array) $model->getResource()->getWebsiteIds($model->getId());
         // Website list that admin is currently trying to assign to current giftwrapping
         $postWebsiteIds = array_intersect((array) $model->getWebsiteIds(), $roleWebsiteIds);
         $websiteIds = array_merge(array_diff($origWebsiteIds, $roleWebsiteIds), $postWebsiteIds);
         $model->setWebsiteIds($websiteIds);
     }
     return $this;
 }
 /**
  * Save attached websites
  *
  * @param  Enterprise_GiftWrapping_Model_Wrapping $wrapping
  * @return void
  */
 public function saveWrappingWebsiteData($wrapping)
 {
     $websiteIds = $wrapping->getWebsiteIds();
     $this->_getWriteAdapter()->delete($this->_websiteTable, array('wrapping_id = ?' => $wrapping->getId()));
     foreach ($websiteIds as $value) {
         $this->_getWriteAdapter()->insert($this->_websiteTable, array('wrapping_id' => $wrapping->getId(), 'website_id' => $value));
     }
 }