예제 #1
0
 public function encode()
 {
     $result = parent::encode();
     if ($this->_request) {
         $params = $this->_request->getParams();
         foreach ($this->_blankableParams as $key) {
             if (isset($params[$key])) {
                 unset($params[$key]);
             }
         }
         // Prevent propagating changes on mageploy's configuration
         if (isset($params['groups']['mageploy'])) {
             unset($params['groups']['mageploy']);
         }
         $result[self::INDEX_EXECUTOR_CLASS] = get_class($this);
         #$result[self::INDEX_CONTROLLER_MODULE] = $this->_request->getControllerModule();
         $result[self::INDEX_CONTROLLER_MODULE] = 'PugMoRe_Mageploy';
         $result[self::INDEX_CONTROLLER_NAME] = $this->_request->getControllerName();
         $result[self::INDEX_ACTION_NAME] = $this->_request->getActionName();
         $result[self::INDEX_ACTION_PARAMS] = $this->_encodeParams($params);
         $result[self::INDEX_ACTION_DESCR] = sprintf("%s System Config", ucfirst($this->_request->getActionName()));
         $result[self::INDEX_VERSION] = $this->_getVersion();
     } else {
         $result = false;
     }
     return $result;
 }
예제 #2
0
파일: Page.php 프로젝트: ngreimel/mageploy
 public function encode()
 {
     $result = parent::encode();
     if ($this->_request) {
         $params = $this->_request->getParams();
         // convert store IDs
         foreach ($params['stores'] as $i => $storeId) {
             $storeUuid = Mage::app()->getStore($storeId)->getCode();
             $params['stores'][$i] = $storeUuid;
         }
         // convert ID, if page already exists
         $new = 'new';
         $identifier = $params['identifier'];
         if (isset($params['page_id'])) {
             $new = 'existing';
             // Read the identifier from existing page; in case of delete,
             // in fact, the  $params['identifier'] does not contain any value
             $identifier = Mage::getModel('cms/page')->load($params['page_id'])->getIdentifier();
             $params['page_id'] = $identifier . self::UUID_SEPARATOR . implode(self::UUID_SEPARATOR, $params['stores']);
         }
         foreach ($this->_blankableParams as $key) {
             if (isset($params[$key])) {
                 unset($params[$key]);
             }
         }
         $result[self::INDEX_EXECUTOR_CLASS] = get_class($this);
         $result[self::INDEX_CONTROLLER_MODULE] = $this->_request->getControllerModule();
         $result[self::INDEX_CONTROLLER_NAME] = $this->_request->getControllerName();
         $result[self::INDEX_ACTION_NAME] = $this->_request->getActionName();
         $result[self::INDEX_ACTION_PARAMS] = $this->_encodeParams($params);
         $result[self::INDEX_ACTION_DESCR] = sprintf("%s %s CMS Page '%s'", ucfirst($this->_request->getActionName()), $new, $identifier);
         $result[self::INDEX_VERSION] = $this->_getVersion();
     } else {
         $result = false;
     }
     return $result;
 }
예제 #3
0
 public function encode()
 {
     $result = parent::encode();
     if ($this->_request) {
         $params = $this->_request->getParams();
         // Init log vars
         $new = 'new';
         $websiteCode = isset($params['website']) ? $params['website']['code'] : '<undefined>';
         $actionName = $this->_request->getActionName();
         switch ($params['store_action']) {
             //
             // Handle saving of existing Website
             //
             case 'edit':
                 // Adapt log vars
                 $new = 'existing';
                 $website = Mage::getModel('core/website')->load($params['website']['website_id']);
                 if ($website->getId()) {
                     $websiteCode = $website->getCode();
                 }
                 // Convert Default Group ID
                 $defaultGroupId = $params['website']['default_group_id'];
                 $defaultGroup = Mage::getModel('core/store_group')->load($defaultGroupId);
                 if ($defaultGroup->getId()) {
                     $params['website']['default_group_id'] = $defaultGroup->getName();
                 }
                 // Convert Website ID
                 $params['website']['website_id'] = $websiteCode;
                 // break intentionally omitted
                 //
                 // Handle adding new Website
                 //
             // break intentionally omitted
             //
             // Handle adding new Website
             //
             case 'add':
                 // Nothing to convert
                 break;
                 //
                 // Handle deleting existing Website
                 // store_action parameter is undefined in case of delete
                 //
             //
             // Handle deleting existing Website
             // store_action parameter is undefined in case of delete
             //
             default:
                 // Adapt log vars and Convert Item ID
                 $new = 'existing';
                 $actionName = 'delete';
                 $website = Mage::getModel('core/website')->load($params['item_id']);
                 if ($website->getId()) {
                     $websiteCode = $params['item_id'] = $website->getCode();
                 }
                 break;
         }
         foreach ($this->_blankableParams as $key) {
             if (isset($params[$key])) {
                 unset($params[$key]);
             }
         }
         $result[self::INDEX_EXECUTOR_CLASS] = get_class($this);
         $result[self::INDEX_CONTROLLER_MODULE] = $this->_request->getControllerModule();
         $result[self::INDEX_CONTROLLER_NAME] = $this->_request->getControllerName();
         $result[self::INDEX_ACTION_NAME] = $this->_request->getActionName();
         $result[self::INDEX_ACTION_PARAMS] = $this->_encodeParams($params);
         $result[self::INDEX_ACTION_DESCR] = sprintf("%s %s Website '%s'", ucfirst($actionName), $new, $websiteCode);
         $result[self::INDEX_VERSION] = $this->_getVersion();
     }
     return $result;
 }
예제 #4
0
 public function encode()
 {
     $result = parent::encode();
     if ($this->_request) {
         $params = $this->_request->getParams();
         $attributeId = 0;
         if (isset($params['attribute_code'])) {
             // new entity
             // in case of options the only action we have to take is that of
             // converting Store IDs to Store UUIDs which is done below
             $isNew = true;
             #$params['mageploy_uuid'] = $params['attribute_code'];
             $attributeUuid = $params['attribute_code'];
         } else {
             // existing entity
             // in case of options the only thing we can do is considering
             // all options as new; when decoding we will try to guess if
             // existing options have changed; there isn't any way of
             // uniquely idenfifying an option
             $attributeId = $params['attribute_id'];
             $attribute = Mage::getModel('catalog/entity_attribute')->load($attributeId);
             #$params['mageploy_uuid'] = $attribute->getAttributeCode();
             $attributeUuid = $attribute->getAttributeCode();
             $params['attribute_id'] = $attributeUuid;
             $isNew = false;
         }
         // Attribute Options
         if (isset($params['option'])) {
             $newOption = $params['option'];
             $option = $params['option'];
             foreach ($option['value'] as $optionId => $optionValues) {
                 foreach ($optionValues as $storeId => $value) {
                     if (!$storeId) {
                         if (is_numeric($optionId)) {
                             $optionUuid = 'existing_opt' . self::UUID_SEPARATOR . $value;
                         } else {
                             $optionUuid = 'new_opt' . self::UUID_SEPARATOR . $optionId;
                         }
                         #continue;
                     }
                     $storeCode = Mage::getModel('core/store')->load($storeId)->getCode();
                     unset($newOption['value'][$optionId][$storeId]);
                     $newOption['value'][$optionId][$storeCode] = $value;
                 }
                 $newOption['value'][$optionUuid] = $newOption['value'][$optionId];
                 unset($newOption['value'][$optionId]);
             }
             foreach ($option['order'] as $optionId => $order) {
                 $value = $this->_getAdminOptionValueByOptionId($attributeId, $optionId);
                 if (is_numeric($optionId)) {
                     $optionUuid = 'existing_opt' . self::UUID_SEPARATOR . $value;
                 } else {
                     $optionUuid = 'new_opt' . self::UUID_SEPARATOR . $optionId;
                 }
                 unset($newOption['order'][$optionId]);
                 $newOption['order'][$optionUuid] = $order;
             }
             foreach ($option['delete'] as $optionId => $delete) {
                 $value = $this->_getAdminOptionValueByOptionId($attributeId, $optionId);
                 if (is_numeric($optionId)) {
                     $optionUuid = 'existing_opt' . self::UUID_SEPARATOR . $value;
                 } else {
                     $optionUuid = 'new_opt' . self::UUID_SEPARATOR . $optionId;
                 }
                 unset($newOption['delete'][$optionId]);
                 $newOption['delete'][$optionUuid] = $delete;
             }
             $params['option'] = $newOption;
         }
         // Default Option
         if (isset($params['default'])) {
             $optionId = $params['default'][0];
             if (is_numeric($optionId)) {
                 $value = $this->_getAdminOptionValueByOptionId($attributeId, $optionId);
                 $params['default'][0] = 'existing_opt' . self::UUID_SEPARATOR . $value;
             } else {
                 $params['default'][0] = 'new_opt' . self::UUID_SEPARATOR . $optionId;
             }
             #$params['default'][0] = 'option_' . $params['default'][0]; // I don't remember what was this intended for, so I comment it :-(
         }
         // Convert Frontend Label's Store Ids
         $newFrontendLabel = array();
         if (isset($params['frontend_label'])) {
             foreach ($params['frontend_label'] as $storeId => $value) {
                 $code = Mage::getModel('core/store')->load($storeId)->getCode();
                 $newFrontendLabel[$code] = $value;
             }
             $params['frontend_label'] = $newFrontendLabel;
         }
         foreach ($this->_blankableParams as $key) {
             if (isset($params[$key])) {
                 unset($params[$key]);
             }
         }
         $result[self::INDEX_EXECUTOR_CLASS] = get_class($this);
         $result[self::INDEX_CONTROLLER_MODULE] = $this->_request->getControllerModule();
         $result[self::INDEX_CONTROLLER_NAME] = $this->_request->getControllerName();
         $result[self::INDEX_ACTION_NAME] = $this->_request->getActionName();
         $result[self::INDEX_ACTION_PARAMS] = $this->_encodeParams($params);
         $result[self::INDEX_ACTION_DESCR] = sprintf("%s %s Attribute with UUID '%s'", ucfirst($this->_request->getActionName()), $isNew ? 'new' : 'existing', $attributeUuid);
         $result[self::INDEX_VERSION] = $this->_getVersion();
     } else {
         $result = false;
     }
     return $result;
 }
예제 #5
0
 public function encode()
 {
     $result = parent::encode();
     if ($this->_request) {
         $params = $this->_request->getParams();
         $newOrExisting = '';
         if (isset($params['attribute_set_name'])) {
             // new entity
             $params['mageploy_uuid'] = $params['attribute_set_name'];
             $newOrExisting = 'new';
         } else {
             // existing entity
             $attributeSet = Mage::getModel('eav/entity_attribute_set')->load($params['id']);
             $params['mageploy_uuid'] = $attributeSet->getAttributeSetName();
             $newOrExisting = 'existing';
         }
         if (isset($params['skeleton_set'])) {
             $skeletonSet = Mage::getModel('eav/entity_attribute_set')->load($params['skeleton_set']);
             $params['skeleton_set'] = $skeletonSet->getAttributeSetName();
         }
         foreach ($this->_blankableParams as $key) {
             if (isset($params[$key])) {
                 unset($params[$key]);
             }
         }
         // json decode $params['data']
         $data = Mage::helper('core')->jsonDecode($params['data']);
         if (isset($data['form_key'])) {
             unset($data['form_key']);
         }
         $helper = Mage::helper('pugmore_mageploy');
         // $data['attributes'] contains the following
         // eav_entity_attribute table values
         //
         // [0] attribute_id
         // [1] attribute_group_id
         // [2] sort_order
         // [3] eav_attribute_id (empty if it's a new association)
         foreach ($data['attributes'] as $i => $attribute) {
             $attributeId = $attribute[0];
             $attributeGroupId = $attribute[1];
             $eavAttributeId = $attribute[3];
             $attributeUuid = $helper->getAttributeCodeFromId($attributeId);
             $entityAttribute = $helper->getEntityAttribute($attributeUuid, $attributeGroupId);
             $attributeSetId = $entityAttribute->getAttributeSetId();
             $attributeSet = Mage::getModel('eav/entity_attribute_set')->load($attributeSetId);
             $attributeSetUuid = $attributeSet->getAttributeSetName();
             if (!strncmp($attributeGroupId, 'ynode', strlen('ynode'))) {
                 $attributeGroupUuid = $attributeGroupId;
             } else {
                 $attributeGroup = Mage::getModel('eav/entity_attribute_group')->load($attributeGroupId);
                 $attributeGroupUuid = $attributeGroup->getAttributeGroupName() . self::UUID_SEPARATOR . $attributeSetUuid;
             }
             $eavAttributeUuid = $attributeGroupUuid . self::UUID_SEPARATOR . $attributeUuid;
             // Convert IDs into UUIDs
             $data['attributes'][$i][0] = $attributeUuid;
             $data['attributes'][$i][1] = $attributeGroupUuid;
             if (!empty($data['attributes'][$i][3])) {
                 $data['attributes'][$i][3] = $eavAttributeUuid;
             }
         }
         // $data['groups'] contains the following
         // eav_attribute_group table values
         //
         // [0] attribute_group_id or "ynode-NUM" for new
         // [1] attribute_group_name
         // [2] sort_order
         foreach ($data['groups'] as $i => $group) {
             $attributeGroupId = $group[0];
             if (!strncmp($attributeGroupId, 'ynode', strlen('ynode'))) {
                 continue;
             }
             $attributeGroup = Mage::getModel('eav/entity_attribute_group')->load($attributeGroupId);
             $attributeSetId = $attributeGroup->getAttributeSetId();
             $attributeSet = Mage::getModel('eav/entity_attribute_set')->load($attributeSetId);
             $attributeSetUuid = $attributeSet->getAttributeSetName();
             $attributeGroupUuid = $attributeGroup->getAttributeGroupName() . self::UUID_SEPARATOR . $attributeSetUuid;
             $data['groups'][$i][0] = $attributeGroupUuid;
         }
         // $data['not_attributes'] contains the ID of attributes to be
         // unassociated
         foreach ($data['not_attributes'] as $i => $attributeId) {
             if (empty($attributeId)) {
                 continue;
             }
             $eavEntityAttributeRow = $helper->getEavEntityAttributeRow($attributeId);
             $attributeSetId = $eavEntityAttributeRow['attribute_set_id'];
             $attributeSet = Mage::getModel('eav/entity_attribute_set')->load($attributeSetId);
             $attributeSetUuid = $attributeSet->getAttributeSetName();
             $attributeGroupId = $eavEntityAttributeRow['attribute_group_id'];
             $attributeGroup = Mage::getModel('eav/entity_attribute_group')->load($attributeGroupId);
             $attributeGroupUuid = $attributeGroup->getAttributeGroupName() . self::UUID_SEPARATOR . $attributeSetUuid;
             $attributeUuid = $helper->getAttributeCodeFromId($eavEntityAttributeRow['attribute_id']);
             $eavEntityAttributeUuid = $attributeGroupUuid . self::UUID_SEPARATOR . $attributeUuid;
             $data['not_attributes'][$i] = $eavEntityAttributeUuid;
         }
         // $data['removeGroups'] contains the ID of Attribute Group to be
         // deleted
         foreach ($data['removeGroups'] as $i => $groupId) {
             if (empty($groupId)) {
                 continue;
             }
             $group = Mage::getModel('eav/entity_attribute_group')->load($groupId);
             $attributeSetId = $group->getAttributeSetId();
             $attributeSet = Mage::getModel('eav/entity_attribute_set')->load($attributeSetId);
             $attributeSetUuid = $attributeSet->getAttributeSetName();
             $attributeGroupUuid = $group->getAttributeGroupName() . self::UUID_SEPARATOR . $attributeSetUuid;
             $data['removeGroups'][$i] = $attributeGroupUuid;
         }
         // The json encoding is left to the decode() function
         $params['data'] = $data;
         $result[self::INDEX_EXECUTOR_CLASS] = get_class($this);
         $result[self::INDEX_CONTROLLER_MODULE] = $this->_request->getControllerModule();
         $result[self::INDEX_CONTROLLER_NAME] = $this->_request->getControllerName();
         $result[self::INDEX_ACTION_NAME] = $this->_request->getActionName();
         $result[self::INDEX_ACTION_PARAMS] = $this->_encodeParams($params);
         $result[self::INDEX_ACTION_DESCR] = sprintf("%s %s Attribute Set with UUID '%s'", ucfirst($this->_request->getActionName()), $newOrExisting, $params['mageploy_uuid']);
         $result[self::INDEX_VERSION] = $this->_getVersion();
     } else {
         $result = false;
     }
     return $result;
 }
예제 #6
0
파일: Group.php 프로젝트: ngreimel/mageploy
 public function encode()
 {
     $result = parent::encode();
     $helper = Mage::helper('pugmore_mageploy');
     if ($this->_request) {
         $params = $this->_request->getParams();
         // Init log vars
         $new = 'new';
         $groupName = isset($params['group']) ? $params['group']['name'] : '<undefined>';
         $actionName = $this->_request->getActionName();
         switch ($params['store_action']) {
             //
             // Handle saving of existing Website
             //
             case 'edit':
                 // Adapt log vars
                 $new = 'existing';
                 $group = Mage::getModel('core/store_group')->load($params['group']['group_id']);
                 if ($group->getId()) {
                     // refer to old Group Name in case of edit
                     $groupName = $group->getName();
                 }
                 // Convert Default Store ID
                 $defaultStoreId = $params['group']['default_store_id'];
                 $defaultStore = Mage::getModel('core/store')->load($defaultStoreId);
                 $params['group']['default_store_id'] = $defaultStore->getCode();
                 // break intentionally omitted
                 //
                 // Handle adding new Group
                 //
             // break intentionally omitted
             //
             // Handle adding new Group
             //
             case 'add':
                 // Convert Group ID
                 $website = Mage::getModel('core/website')->load($params['group']['website_id']);
                 $params['group']['group_id'] = $groupName;
                 // Convert Website ID
                 $params['group']['website_id'] = $website->getCode();
                 // Convert Root Category ID
                 $rootCategoryId = $params['group']['root_category_id'];
                 $rootCategory = Mage::getModel('catalog/category')->load($rootCategoryId);
                 $rootCategoryUuid = $helper->getCategoryUuidFromPath($rootCategory->getPath(), null, self::UUID_SEPARATOR);
                 $params['group']['root_category_id'] = $rootCategoryUuid;
                 break;
                 //
                 // Handle deleting existing Website
                 // store_action parameter is undefined in case of delete
                 //
             //
             // Handle deleting existing Website
             // store_action parameter is undefined in case of delete
             //
             default:
                 // Adapt log vars and Convert Item ID
                 $new = 'existing';
                 $actionName = 'delete';
                 $group = Mage::getModel('core/store_group')->load($params['item_id']);
                 if ($group->getId()) {
                     $groupName = $group->getName();
                     $website = Mage::getModel('core/website')->load($group->getWebsiteId());
                     $params['item_id'] = $website->getCode() . self::UUID_SEPARATOR . $group->getName();
                 }
                 break;
         }
         foreach ($this->_blankableParams as $key) {
             if (isset($params[$key])) {
                 unset($params[$key]);
             }
         }
         $result[self::INDEX_EXECUTOR_CLASS] = get_class($this);
         $result[self::INDEX_CONTROLLER_MODULE] = $this->_request->getControllerModule();
         $result[self::INDEX_CONTROLLER_NAME] = $this->_request->getControllerName();
         $result[self::INDEX_ACTION_NAME] = $this->_request->getActionName();
         $result[self::INDEX_ACTION_PARAMS] = $this->_encodeParams($params);
         $result[self::INDEX_ACTION_DESCR] = sprintf("%s %s Store Group '%s'", ucfirst($actionName), $new, $groupName);
         $result[self::INDEX_VERSION] = $this->_getVersion();
     }
     return $result;
 }
예제 #7
0
 public function encode()
 {
     $result = parent::encode();
     if ($this->_request) {
         $params = $this->_request->getParams();
         // Id
         $newOrExisting = '';
         if (isset($params['id'])) {
             $categoryId = $params['id'];
             $newOrExisting = 'existing';
             $existingCategory = Mage::getModel('catalog/category')->load($categoryId);
             $categoryName = $existingCategory->getName();
             $path = $existingCategory->getPath();
             $categoryUuid = $this->_getCategoryUuidFromPath($path);
             $params['id'] = $categoryUuid;
         } else {
             $categoryId = false;
             $newOrExisting = 'new';
             $categoryName = $params['general']['name'];
             $parentId = $params['general']['path'];
             $parentCategory = Mage::getModel('catalog/category')->load($parentId);
             $path = $parentCategory->getPath();
             //$categoryUuid = $this->_getCategoryUuidFromPath($path, $params['general']['name']);
         }
         // Store
         if (array_key_exists('store', $params)) {
             $storeId = $params['store'];
         } else {
             $storeId = 0;
         }
         if ($storeId) {
             $storeUuid = Mage::app()->getStore($storeId)->getCode();
         } else {
             $storeUuid = $storeId;
         }
         $params['store'] = $storeUuid;
         // Parent
         if (array_key_exists('parent', $params)) {
             $parentId = $params['parent'];
         } else {
             $parentId = 0;
         }
         if ($parentId) {
             $parentCategory = Mage::getModel('catalog/category')->load($parentId);
             $parentUuid = $this->_getCategoryUuidFromPath($parentCategory->getPath());
         } else {
             $parentUuid = $parentId;
         }
         $params['parent'] = $parentUuid;
         // Associated Products
         $associatedProductIds = explode('&', $params['category_products']);
         $associatedProductUuids = array();
         foreach ($associatedProductIds as $i => $association) {
             list($id, $position) = explode('=', $association);
             $prod = Mage::getModel('catalog/product')->load($id);
             $associatedProductUuids[] = sprintf("%s=%d", $prod->getSku(), $position);
         }
         $params['category_products'] = implode('&', $associatedProductUuids);
         // General
         if (isset($params['general']['id'])) {
             $params['general']['id'] = $params['id'];
         }
         if (isset($params['general']['path'])) {
             if (isset($params['id'])) {
                 $params['general']['path'] = $params['id'];
             } else {
                 $parentId = $params['general']['path'];
                 $parentCategory = Mage::getModel('catalog/category')->load($parentId);
                 $path = $parentCategory->getPath();
                 $params['general']['path'] = $this->_getCategoryUuidFromPath($path);
             }
         }
         // pid, paid, aid (move action)
         $moveIds = array('pid', 'aid', 'paid');
         foreach ($moveIds as $key) {
             if (isset($params[$key])) {
                 $moveNodeId = $params[$key];
                 $moveNodeCategory = Mage::getModel('catalog/category')->load($moveNodeId);
                 $moveNodeUuid = $this->_getCategoryUuidFromPath($moveNodeCategory->getPath());
                 $params[$key] = $moveNodeUuid;
             }
         }
         foreach ($this->_blankableParams as $key) {
             if (isset($params[$key])) {
                 unset($params[$key]);
             }
         }
         $result[self::INDEX_EXECUTOR_CLASS] = get_class($this);
         $result[self::INDEX_CONTROLLER_MODULE] = $this->_request->getControllerModule();
         $result[self::INDEX_CONTROLLER_NAME] = $this->_request->getControllerName();
         $result[self::INDEX_ACTION_NAME] = $this->_request->getActionName();
         $result[self::INDEX_ACTION_PARAMS] = $this->_encodeParams($params);
         $result[self::INDEX_ACTION_DESCR] = sprintf("%s %s Category named '%s'", ucfirst($this->_request->getActionName()), $newOrExisting, $categoryName);
         $result[self::INDEX_VERSION] = $this->_getVersion();
     } else {
         $result = false;
     }
     return $result;
 }