diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/115_preview b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/115_preview
new file mode 100644
index 0000000..9613b69
--- /dev/null
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/115_preview
@@ -0,0 +1,27 @@
+ ${{entity}}Data = Mage::registry('current_{{entity}}')->getData();
+ $storeIds = ${{entity}}Data['store_id'];
+ for ($i = 0; $i < count($storeIds); ++$i) {
+ if ($storeIds[$i] == 0) {
+ $storeIds[$i] = 1;
+ }
+ }
+ $storeIds = array_unique($storeIds);
+ foreach ($storeIds as $storeId) {
+ $store = Mage::app()->getStore($storeId);
+ ${{entity}} = Mage::registry('current_{{entity}}');
+ $linkToPreview = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
+ if ($prefix = Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/url_prefix')){
+ $linkToPreview .= $prefix.'/';
+ }
+ $linkToPreview .= ${{entity}}->getUrlKey();
+ if ($suffix = Mage::getStoreConfig('{{namespace}}_{{module}}/{{entity}}/url_suffix')){
+ $linkToPreview .= '.'.$suffix;
+ }
+ $linkToPreview .= '?mode=preview';
+ $fieldset->addField('preview-store-'.$storeId, 'link', array(
+ 'label' => 'Preview for Store '.$store->getName(),
+ 'href' => $linkToPreview,
+ 'value' => 'Open preview',
+ 'onclick' => 'window.open(\''.$linkToPreview.'\', \'_blank\'); return false;'
+ ));
+ }
\ No newline at end of file
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/140_add_values_not_tree b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/140_add_values_not_tree
index ff8c62f..9bd400f 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/140_add_values_not_tree
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Edit/Tab/Form/140_add_values_not_tree
@@ -8,6 +8,6 @@
} elseif (Mage::registry('current_{{entity}}')) {
$formValues = array_merge($formValues, Mage::registry('current_{{entity}}')->getData());
}
- $form->setValues($formValues);
+ $form->addValues($formValues);
return parent::_prepareForm();
}
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/115_mass_action_copy_to_store_view b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/115_mass_action_copy_to_store_view
new file mode 100644
index 0000000..0e7db72
--- /dev/null
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Block/Adminhtml/Entity/Grid/115_mass_action_copy_to_store_view
@@ -0,0 +1,30 @@
+ $storeViewList = array();
+ $storeViewList['-1'] = Mage::helper('{{namespace}}_{{module}}')->__('Keep Existing');
+ foreach (Mage::app()->getWebsites() as $website) {
+ foreach ($website->getGroups() as $group) {
+ $stores = $group->getStores();
+ foreach ($stores as $store) {
+ $storeViewList[$store->getId()] = $website->getName() . ' / ' . $group->getName() . ' / ' . $store->getName();
+ }
+ }
+ }
+ $this->getMassactionBlock()->addItem('copy_to_store_view', array(
+ 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Copy to store view'),
+ 'url' => $this->getUrl('*/*/massCopyToStoreView', array('_current' => true)),
+ 'additional' => array(
+ 'store' => array(
+ 'name' => 'storeview',
+ 'type' => 'select',
+ 'class' => 'required-entry',
+ 'style' => 'max-width:100px',
+ 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Store View'),
+ 'values' => $storeViewList
+ ),
+ 'suffix' => array(
+ 'name' => 'suffix',
+ 'type' => 'text',
+ 'style' => 'width:50px',
+ 'label' => Mage::helper('{{namespace}}_{{module}}')->__('Suffix for URL Key'),
+ )
+ )
+ ));
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Adminhtml/Module/010_content b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Adminhtml/Module/010_content
index 9b224b0..2af2a06 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Adminhtml/Module/010_content
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Adminhtml/Module/010_content
@@ -25,7 +25,7 @@ class {{Namespace}}_{{Module}}_Controller_Adminhtml_{{Module}} extends Mage_Admi
if (isset($data[$input]['delete'])) {
return '';
} else {
- $uploader = new Varien_File_Uploader($input);
+ $uploader = new Mage_Core_Model_File_Uploader($input);
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$uploader->setAllowCreateFolders(true);
@@ -33,7 +33,7 @@ class {{Namespace}}_{{Module}}_Controller_Adminhtml_{{Module}} extends Mage_Admi
return $result['file'];
}
} catch (Exception $e) {
- if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
+ if ($e->getCode() != Mage_Core_Model_Uploader::TMP_NAME_EMPTY) {
throw $e;
} else {
if (isset($data[$input]['value'])) {
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Router/030_footer b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Router/030_footer
index 1e43c1f..f6dff5a 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Router/030_footer
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Controller/Router/030_footer
@@ -22,9 +22,10 @@
$urlKey = substr($urlKey, 0, -strlen($settings['suffix']) - 1);
}
$model = Mage::getModel($settings->getModel());
- $id = $model->checkUrlKey($urlKey, Mage::app()->getStore()->getId());
+ $isPreview = Mage::app()->getFrontController()->getRequest()->getParam('mode') == 'preview';
+ $id = $model->checkUrlKey($urlKey, Mage::app()->getStore()->getId(), !$isPreview);
if ($id) {
- if ($settings->getCheckPath() && !$model->load($id)->getStatusPath()) {
+ if ($settings->getCheckPath() && !$model->load($id)->getStatusPath() && !$isPreview) {
continue;
}
$request->setModuleName('{{frontKey}}')
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Image/Abstract/010_content b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Image/Abstract/010_content
index 03f41fd..01d8f38 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Image/Abstract/010_content
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Helper/Image/Abstract/010_content
@@ -153,8 +153,13 @@ abstract class {{Namespace}}_{{Module}}_Helper_Image_Abstract extends Mage_Core_
$this->_resized = false;
$this->_adaptiveResize = 'center';
+ $imageFilePath = $this->getImageBaseDir().$this->_image;
+ if (!file_exists($imageFilePath)) {
+ Mage::helper('core/file_storage_database')->saveFileToFilesystem($imageFilePath);
+ }
+
try {
- $this->_getImageProcessor()->open($this->getImageBaseDir().$this->_image);
+ $this->_getImageProcessor()->open($imageFilePath);
} catch (Exception $e) {
$this->_openError = $e->getMessage();
try {
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/070_url_rewrite b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/070_url_rewrite
index 8b6de35..15cc551 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/070_url_rewrite
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/070_url_rewrite
@@ -31,7 +31,7 @@
* @return mixed
* {{qwertyuiop}}
*/
- public function checkUrlKey($urlKey, $active = true)
+ public function checkUrlKey($urlKey, $storeId, $active = true)
{
- return $this->_getResource()->checkUrlKey($urlKey, $active);
+ return $this->_getResource()->checkUrlKey($urlKey, $storeId, $active);
}
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/File/010_content b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/File/010_content
index 9fbcd74..1400bfc 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/File/010_content
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/File/010_content
@@ -31,7 +31,7 @@ class {{Namespace}}_{{Module}}_Model_{{Entity}}_Attribute_Backend_File extends M
$path = Mage::helper('{{namespace}}_{{module}}/{{entity}}')->getFileBaseDir();
try {
- $uploader = new Varien_File_Uploader($this->getAttribute()->getName());
+ $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
//set allowed file extensions if you need
//$uploader->setAllowedExtensions(array('mp4', 'mov', 'f4v', 'flv'));
$uploader->setAllowRenameFiles(true);
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/Image/010_content b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/Image/010_content
index 204c1d0..ce17b07 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/Image/010_content
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/Model/Entity/Attribute/Backend/Image/010_content
@@ -31,7 +31,7 @@ class {{Namespace}}_{{Module}}_Model_{{Entity}}_Attribute_Backend_Image extends
$path = Mage::helper('{{namespace}}_{{module}}/{{entity}}_image')->getImageBaseDir();
try {
- $uploader = new Varien_File_Uploader($this->getAttribute()->getName());
+ $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$result = $uploader->save($path);
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/110_center b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/110_center
index 3c0d9d4..cc00a24 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/110_center
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/Adminhtml/Module/EntityControllerFlatNotTree/110_center
@@ -119,3 +119,59 @@
}
$this->_redirect('*/*/index');
}
+ /**
+ * mass copy to store view - action
+ *
+ * @access public
+ * @return void
+ * {{qwertyuiop}}
+ */
+ public function massCopyToStoreViewAction() {
+ ${{entity}}Ids = $this->getRequest()->getParam('{{entity}}');
+ $store = $this->getRequest()->getParam('storeview');
+ $suffix = $this->getRequest()->getParam('suffix');
+
+ if (!is_array(${{entity}}Ids)) {
+ $this->_getSession()->addError(
+ Mage::helper('{{namespace}}_{{module}}')->__('Please select {{entitiesLabel}}.')
+ );
+ } else {
+ try {
+ foreach (${{entity}}Ids as ${{entity}}Id) {
+ ${{entity}} = Mage::getModel('{{namespace}}_{{module}}/{{entity}}')->load(${{entity}}Id);
+ $data = ${{entity}}->getData();
+ $selectedProductsFullInformation = ${{entity}}->getSelectedProducts();
+ $selectedProducts = array();
+ foreach ($selectedProductsFullInformation as $selectedProductsFullInformation) {
+ $selectedProduct = $selectedProductsFullInformation->getData();
+ $selectedProducts[$selectedProduct['entity_id']] = array(position => $selectedProduct['position']);
+ }
+ $selectedCategoriesFullInformation = ${{entity}}->getSelectedCategories();
+ $selectedCategories = array();
+ foreach ($selectedCategoriesFullInformation as $selectedCategoryFullInformation) {
+ $selectedCategory = $selectedCategoryFullInformation->getData();
+ $selectedCategories[] = $selectedCategory['entity_id'];
+ }
+ if ($store != -1) {
+ $data['store_id'] = array($store);
+ }
+ if (strlen($suffix) > 0) {
+ $data['url_key'] = $data['url_key'] . '-' . $suffix;
+ }
+ unset($data['entity_id'], $data['created_at'], $data['updated_at']);
+ $data['status'] = 0;
+ $model = Mage::getModel('{{namespace}}_{{module}}/{{entity}}');
+ $model->setData($data);
+ $model->setProductsData($selectedProducts);
+ $model->setCategoriesData($selectedCategories);
+ $model->save();
+ }
+ $this->_getSession()->addSuccess(
+ Mage::helper('{{namespace}}_{{module}}')->__('Total of %d {{entitiesLabel}} were successfully copied.', count(${{entity}}Ids))
+ );
+ } catch (Exception $e) {
+ $this->_getSession()->addError($e->getMessage() . ' ' . Mage::helper('{{namespace}}_{{module}}')->__('There was an error copying {{entitiesLabel}}.'));
+ }
+ }
+ $this->_redirect('*/*/');
+ }
\ No newline at end of file
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/050_view b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/050_view
index 49262cb..5b0b909 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/050_view
+++ b/app/code/community/Ultimate/ModuleCreator/etc/source/app/code/controllers/EntityController/050_view
@@ -14,7 +14,7 @@
->load(${{entity}}Id);
if (!${{entity}}->getId()) {
return false;
- } elseif (!${{entity}}->getStatus()) {
+ } elseif (!${{entity}}->getStatus() && $this->getRequest()->getParam('mode') != 'preview') {
return false;
}
return ${{entity}};
@@ -34,3 +34,6 @@
$this->_forward('no-route');
return;
}
+ if ($this->getRequest()->getParam('mode') == 'preview') {
+ $this->getResponse()->setHeader('HTTP/1.0', '404', true);
+ }
diff --git a/app/code/community/Ultimate/ModuleCreator/etc/umc_source.xml b/app/code/community/Ultimate/ModuleCreator/etc/umc_source.xml
index 19200d3..61b4452 100644
--- a/app/code/community/Ultimate/ModuleCreator/etc/umc_source.xml
+++ b/app/code/community/Ultimate/ModuleCreator/etc/umc_source.xml
@@ -1242,8 +1242,12 @@
- 120
+ 110
+
+ 115_preview
+ 115
+
120_stores
@@ -1615,6 +1619,15 @@
110_mass_action_top
110
+
+ 115_mass_action_copy_to_store_view
+ 115
+
+
+
+
+
+
120_mass_action_flags
attribute