├── .gitignore ├── Block └── Adminhtml │ ├── Catalog.php │ ├── Catalog │ ├── Edit.php │ ├── Edit │ │ ├── Form.php │ │ └── Form.php_ │ └── Grid.php │ ├── Category.php │ ├── Category │ ├── Edit.php │ ├── Edit │ │ └── Form.php │ └── Grid.php │ ├── Product.php │ └── Product │ ├── Edit.php │ ├── Edit │ ├── Form.php │ └── Form.php_orginal │ └── Grid.php ├── Controller └── Adminhtml │ ├── Action.php │ ├── Catalog.php │ ├── Catalog.php_speed │ ├── Catalog │ ├── Edit.php │ ├── Grid.php │ ├── Index.php │ ├── Save.php │ └── Save.php_speed │ ├── Category.php │ ├── Category │ ├── Edit.php │ ├── Grid.php │ ├── Index.php │ └── Save.php │ ├── Product.php │ └── Product │ ├── Edit.php │ ├── Grid.php │ ├── Index.php │ └── Save.php ├── README.md ├── composer.json ├── etc ├── acl.xml ├── adminhtml │ ├── menu.xml │ └── routes.xml └── module.xml ├── media └── magento-2-multitranslate.png ├── registration.php └── view └── adminhtml ├── layout ├── multitranslate_catalog_edit.xml ├── multitranslate_catalog_grid.xml ├── multitranslate_catalog_index.xml ├── multitranslate_category_edit.xml ├── multitranslate_category_grid.xml ├── multitranslate_category_index.xml ├── multitranslate_product_edit.xml ├── multitranslate_product_grid.xml ├── multitranslate_product_index.xml └── multitranslate_product_new.xml └── templates └── html └── pager.phtml /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | .DS_Store 3 | .AppleDouble 4 | .LSOverride 5 | 6 | # Icon must end with two \r 7 | Icon 8 | 9 | # Thumbnails 10 | ._* 11 | 12 | # Files that might appear in the root of a volume 13 | .DocumentRevisions-V100 14 | .fseventsd 15 | .Spotlight-V100 16 | .TemporaryItems 17 | .Trashes 18 | .VolumeIcon.icns 19 | .com.apple.timemachine.donotpresent 20 | 21 | # Directories potentially created on remote AFP share 22 | .AppleDB 23 | .AppleDesktop 24 | Network Trash Folder 25 | Temporary Items 26 | .apdisk -------------------------------------------------------------------------------- /Block/Adminhtml/Catalog.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 21:49:18 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml; 14 | 15 | class Catalog extends \Magento\Backend\Block\Widget\Grid\Container 16 | { 17 | /** 18 | * Constructor. 19 | */ 20 | protected function _construct() 21 | { 22 | $this->_controller = 'adminhtml_catalog'; 23 | $this->_blockGroup = 'Magepow_MultiTranslate'; 24 | $this->_headerText = __('Catalog'); 25 | parent::_construct(); 26 | $this->removeButton('add'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Block/Adminhtml/Catalog/Edit.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 22:42:25 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Catalog; 14 | 15 | class Edit extends \Magento\Backend\Block\Widget\Form\Container 16 | { 17 | 18 | /** 19 | * Core registry 20 | * 21 | * @var \Magento\Framework\Registry 22 | */ 23 | protected $_coreRegistry = null; 24 | 25 | /** 26 | * @param \Magento\Backend\Block\Widget\Context $context 27 | * @param \Magento\Framework\Registry $registry 28 | * @param array $data 29 | */ 30 | public function __construct( 31 | \Magento\Backend\Block\Widget\Context $context, 32 | \Magento\Framework\Registry $registry, 33 | array $data = [] 34 | ) { 35 | $this->_coreRegistry = $registry; 36 | parent::__construct($context, $data); 37 | } 38 | 39 | /** 40 | * _construct 41 | * @return void 42 | */ 43 | protected function _construct() 44 | { 45 | $this->_objectId = 'category_id'; 46 | $this->_blockGroup = 'Magepow_MultiTranslate'; 47 | $this->_controller = 'adminhtml_catalog'; 48 | 49 | parent::_construct(); 50 | 51 | $this->buttonList->update('delete', 'label', __('Delete')); 52 | $this->buttonList->remove('delete'); 53 | 54 | if ($this->_isAllowedAction('MultiTranslate_Catalog::save')) { 55 | $this->buttonList->update('save', 'label', __('Save')); 56 | $this->buttonList->add( 57 | 'saveandcontinue', 58 | [ 59 | 'label' => __('Save and Continue Edit'), 60 | 'class' => 'save', 61 | 'data_attribute' => [ 62 | 'mage-init' => [ 63 | 'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'], 64 | ], 65 | ] 66 | ], 67 | -100 68 | ); 69 | } 70 | // else { 71 | // $this->buttonList->remove('save'); 72 | // } 73 | 74 | // if ($this->_coreRegistry->registry('category')->getId()) { 75 | $this->buttonList->remove('reset'); 76 | // } 77 | } 78 | 79 | protected function _isAllowedAction($resourceId) 80 | { 81 | return $this->_authorization->isAllowed($resourceId); 82 | } 83 | 84 | /** 85 | * Retrieve the save and continue edit Url. 86 | * 87 | * @return string 88 | */ 89 | protected function getSaveAndContinueUrl() 90 | { 91 | return $this->getUrl( 92 | '*/*/save', 93 | [ 94 | '_current' => true, 95 | 'back' => 'edit', 96 | 'tab' => '{{tab_id}}', 97 | 'store' => $this->getRequest()->getParam('store'), 98 | 'category_id' => $this->getRequest()->getParam('category_id'), 99 | 'current_category_id' => $this->getRequest()->getParam('current_category_id'), 100 | ] 101 | ); 102 | } 103 | 104 | /** 105 | * Retrieve the save and continue edit Url. 106 | * 107 | * @return string 108 | */ 109 | protected function getSaveAndCloseWindowUrl() 110 | { 111 | return $this->getUrl( 112 | '*/*/save', 113 | [ 114 | '_current' => true, 115 | 'back' => 'edit', 116 | 'tab' => '{{tab_id}}', 117 | 'store' => $this->getRequest()->getParam('store'), 118 | 'category_id' => $this->getRequest()->getParam('category_id'), 119 | 'current_category_id' => $this->getRequest()->getParam('current_category_id'), 120 | 'saveandclose' => 1, 121 | ] 122 | ); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Block/Adminhtml/Catalog/Edit/Form.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2020-05-22 11:32:32 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Catalog\Edit; 14 | 15 | class Form extends \Magento\Backend\Block\Widget\Form\Generic 16 | { 17 | 18 | /** 19 | * @var \Magento\Framework\DataObjectFactory 20 | */ 21 | protected $_objectFactory; 22 | protected $_categoryFactory; 23 | protected $_productFactory; 24 | protected $_wysiwygConfig; 25 | protected $_storeManager; 26 | 27 | public function __construct( 28 | \Magento\Backend\Block\Template\Context $context, 29 | \Magento\Framework\Registry $registry, 30 | \Magento\Framework\Data\FormFactory $formFactory, 31 | \Magento\Framework\DataObjectFactory $objectFactory, 32 | \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, 33 | \Magento\Catalog\Model\ProductFactory $productFactory, 34 | \Magento\Catalog\Model\CategoryFactory $categoryFactory, 35 | array $data = [] 36 | ) { 37 | $this->_objectFactory = $objectFactory; 38 | $this->_productFactory = $productFactory; 39 | $this->_categoryFactory = $categoryFactory; 40 | $this->_wysiwygConfig = $wysiwygConfig; 41 | $this->_storeManager = $context->getStoreManager(); 42 | parent::__construct($context, $registry, $formFactory, $data); 43 | } 44 | 45 | protected function _prepareForm() 46 | { 47 | $model = $this->_coreRegistry->registry('category'); 48 | $productCollection = $model->getProductCollection()->addAttributeToSelect('*'); 49 | 50 | $pager = $this->getLayout()->createBlock('Magento\Theme\Block\Html\Pager', 'form.pager') 51 | ->setAvailableLimit(array(5=>5, 10=>10, 15=>15, 20=>20)) 52 | ->setShowPerPage(true) 53 | ->setCollection($productCollection) 54 | ->setTemplate('Magepow_MultiTranslate::html/pager.phtml'); 55 | $this->setChild('pager', $pager); 56 | 57 | /** @var \Magento\Framework\Data\Form $form */ 58 | $form = $this->_formFactory->create( 59 | array( 60 | 'data' => array( 61 | 'id' => 'edit_form', 62 | 'action' => $this->getUrl('*/*/save', ['store' => $this->getRequest()->getParam('store')]), 63 | 'method' => 'post', 64 | 'enctype' => 'multipart/form-data', 65 | ), 66 | ) 67 | ); 68 | $form->setUseContainer(true); 69 | $form->setHtmlIdPrefix('magic_'); 70 | 71 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Catalog Information')]); 72 | 73 | if ($model->getId()) { 74 | $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']); 75 | } 76 | 77 | $note = $fieldset->addField('pager', 'note', array( 78 | 'text' => $this->getPagerHtml() 79 | )); 80 | 81 | $note->setAfterElementHtml( 82 | '' 92 | ); 93 | 94 | $stores = $this->_storeManager->getStores(); 95 | $data = $model->getData(); 96 | $data_form = $data; 97 | foreach ($productCollection as $item) { 98 | $productId = $item->getId(); 99 | $product = $this->_productFactory->create(); 100 | $_product = $product->setStoreId(0)->load($productId); 101 | 102 | $_data = $_product->getData(); 103 | foreach ($_data as $key => $value) { 104 | /* 2 underline fix erro underline attribute short_description */ 105 | $key = $key . '__' . $productId; 106 | $data_form[$key] = $value; 107 | } 108 | $suffix = $productId; 109 | $name = $fieldset->addField("name__$suffix", 'text', 110 | [ 111 | 'label' => __("Name (Default)"), 112 | 'title' => __("Name (Default)"), 113 | 'name' => "name__$suffix", 114 | 'required' => true, 115 | ] 116 | ); 117 | 118 | $fieldset->addField("description__$suffix", 'editor', 119 | [ 120 | 'label' => __('Description (Default)'), 121 | 'title' => __('Description'), 122 | 'name' => "description__$suffix", 123 | 'config' => $this->_wysiwygConfig->getConfig(), 124 | 'wysiwyg' => true, 125 | 'required' => false, 126 | ] 127 | ); 128 | 129 | $fieldset->addField("short_description__$suffix", 'editor', 130 | [ 131 | 'label' => __('Short description (Default)'), 132 | 'title' => __('Short description'), 133 | 'name' => "short_description__$suffix", 134 | 'config' => $this->_wysiwygConfig->getConfig(), 135 | 'wysiwyg' => true, 136 | 'required' => false, 137 | ] 138 | ); 139 | 140 | foreach ($stores as $store) { 141 | $storeId = $store->getId(); 142 | $storeName = $store->getName(); 143 | $groupName = $this->_storeManager->getStore($storeId)->getGroup()->getName(); 144 | $product = $this->_productFactory->create(); 145 | $_product = $product->setStoreId($storeId)->load($productId); 146 | 147 | $nameChecked = !$_product->getExistsStoreValueFlag('name'); 148 | $descriptionChecked = !$_product->getExistsStoreValueFlag('description'); 149 | $short_descriptionChecked = !$_product->getExistsStoreValueFlag('short_description'); 150 | 151 | $_data = $_product->getData(); 152 | foreach ($_data as $key => $value) { 153 | /* 2 underline fix erro underline attribute short_description */ 154 | $key = $key . '__' . $productId . '__' . $storeId; 155 | $data_form[$key] = $value; 156 | } 157 | 158 | /* 2 underline fix erro underline attribute short_description */ 159 | $suffix = $productId . '__' . $storeId; 160 | 161 | $name = $fieldset->addField("name__$suffix", 'text', 162 | [ 163 | 'label' => __("Name ($groupName - $storeName)"), 164 | 'title' => __("Name ($storeName)"), 165 | 'name' => "name__$suffix", 166 | 'required' => true, 167 | ] 168 | ); 169 | 170 | $name_default = $fieldset->addField("use_default[name__$suffix]", 'checkbox', 171 | [ 172 | 'label' => __('Use Default Value'), 173 | 'title' => __('Name'), 174 | 'name' => "use_default[name__$suffix]", 175 | 'value' => 1, 176 | 'checked' => $nameChecked, 177 | 'required' => false, 178 | ] 179 | ); 180 | 181 | $name_default->setAfterElementHtml( 182 | '' 203 | ); 204 | 205 | $fieldset->addField("description__$suffix", 'editor', 206 | [ 207 | 'label' => __("Description ($storeName)"), 208 | 'title' => __("Description ($storeName)"), 209 | 'name' => "description__$suffix", 210 | 'config' => $this->_wysiwygConfig->getConfig(), 211 | 'wysiwyg' => true, 212 | 'required' => false, 213 | ] 214 | ); 215 | 216 | $fieldset->addField("short_description__$suffix", 'editor', 217 | [ 218 | 'label' => __("Short Description ($storeName)"), 219 | 'title' => __("Short Description ($storeName)"), 220 | 'name' => "short_description__$suffix", 221 | 'config' => $this->_wysiwygConfig->getConfig(), 222 | 'wysiwyg' => true, 223 | 'required' => false, 224 | ] 225 | ); 226 | 227 | $fieldset->addField("use_default[description__$suffix]", 'checkbox', 228 | [ 229 | 'label' => __('Use Default Value'), 230 | 'title' => __('Description'), 231 | 'name' => "use_default[description__$suffix]", 232 | 'value' => 1, 233 | 'checked' => $descriptionChecked, 234 | 'required' => false, 235 | ] 236 | ); 237 | 238 | $fieldset->addField("use_default[short_description__$suffix]", 'checkbox', 239 | [ 240 | 'label' => __('Use Default Value'), 241 | 'title' => __('Short Description'), 242 | 'name' => "use_default[short_description__$suffix]", 243 | 'value' => 1, 244 | 'checked' => $short_descriptionChecked, 245 | 'required' => false, 246 | ] 247 | ); 248 | } 249 | } 250 | 251 | $form->addValues($data_form); 252 | 253 | $this->setForm($form); 254 | 255 | return parent::_prepareForm(); 256 | } 257 | 258 | public function getPagerHtml() 259 | { 260 | return $this->getChildHtml('pager'); 261 | } 262 | 263 | } 264 | -------------------------------------------------------------------------------- /Block/Adminhtml/Catalog/Edit/Form.php_: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-27 10:53:14 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Catalog\Edit; 14 | 15 | class Form extends \Magento\Backend\Block\Widget\Form\Generic 16 | { 17 | 18 | /** 19 | * @var \Magento\Framework\DataObjectFactory 20 | */ 21 | protected $_objectFactory; 22 | protected $_categoryFactory; 23 | protected $_productFactory; 24 | protected $_wysiwygConfig; 25 | protected $_storeManager; 26 | 27 | public function __construct( 28 | \Magento\Backend\Block\Template\Context $context, 29 | \Magento\Framework\Registry $registry, 30 | \Magento\Framework\Data\FormFactory $formFactory, 31 | \Magento\Framework\DataObjectFactory $objectFactory, 32 | \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, 33 | \Magento\Catalog\Model\ProductFactory $productFactory, 34 | \Magento\Catalog\Model\CategoryFactory $categoryFactory, 35 | array $data = [] 36 | ) { 37 | $this->_objectFactory = $objectFactory; 38 | $this->_productFactory = $productFactory; 39 | $this->_categoryFactory = $categoryFactory; 40 | $this->_wysiwygConfig = $wysiwygConfig; 41 | $this->_storeManager = $context->getStoreManager(); 42 | parent::__construct($context, $registry, $formFactory, $data); 43 | } 44 | 45 | protected function _prepareForm() 46 | { 47 | $model = $this->_coreRegistry->registry('category'); 48 | $products = $model->getProductCollection()->addAttributeToSelect('*'); 49 | 50 | /** @var \Magento\Framework\Data\Form $form */ 51 | $form = $this->_formFactory->create( 52 | array( 53 | 'data' => array( 54 | 'id' => 'edit_form', 55 | 'action' => $this->getUrl('*/*/save', ['store' => $this->getRequest()->getParam('store')]), 56 | 'method' => 'post', 57 | 'enctype' => 'multipart/form-data', 58 | ), 59 | ) 60 | ); 61 | $form->setUseContainer(true); 62 | $form->setHtmlIdPrefix('magic_'); 63 | 64 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Category Information')]); 65 | 66 | if ($model->getId()) { 67 | $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']); 68 | } 69 | 70 | $product = $this->_productFactory->create(); 71 | 72 | $stores = $this->_storeManager->getStores(); 73 | $data = $model->getData(); 74 | $data_form = $data; 75 | foreach ($products as $item) { 76 | $product_id = $item->getId(); 77 | $_product = $product->load($product_id); 78 | $nameChecked = !$_product->getExistsStoreValueFlag('name'); 79 | 80 | $_data = $_product->getData(); 81 | foreach ($_data as $key => $value) { 82 | $key = $key . '_' . $product_id; 83 | $data_form[$key] = $value; 84 | } 85 | $filed = 'name_' . $product_id; 86 | $name = $fieldset->addField($filed, 'text', 87 | [ 88 | 'label' => __("Name (Default)"), 89 | 'title' => __("Name (Default)"), 90 | 'name' => $filed, 91 | 'required' => true, 92 | ] 93 | ); 94 | 95 | foreach ($stores as $store) { 96 | $store_id = $store->getId(); 97 | $store_name = $store->getName(); 98 | $group_name = $this->_storeManager->getStore($store_id)->getGroup()->getName(); 99 | $_product = $product->setStoreId($store_id)->load($product_id); 100 | 101 | $nameChecked = !$_product->getExistsStoreValueFlag('name'); 102 | 103 | $_data = $_product->getData(); 104 | foreach ($_data as $key => $value) { 105 | $key = $key . '_' . $product_id . '_' . $store_id; 106 | $data_form[$key] = $value; 107 | } 108 | 109 | $filed = 'name_' . $product_id . '_' . $store_id; 110 | $name = $fieldset->addField($filed, 'text', 111 | [ 112 | 'label' => __("Name ($group_name - $store_name)"), 113 | 'title' => __("Name ($store_name)"), 114 | 'name' => $filed, 115 | 'required' => true, 116 | ] 117 | ); 118 | 119 | $name_default = $fieldset->addField("use_default[$filed]", 'checkbox', 120 | [ 121 | 'label' => __('Default Y/N'), 122 | 'title' => __('Name'), 123 | 'name' => "use_default[$filed]", 124 | 'value' => 1, 125 | 'checked' => $nameChecked, 126 | 'required' => false, 127 | ] 128 | ); 129 | 130 | $name_default->setAfterElementHtml( 131 | '' 152 | ); 153 | 154 | } 155 | } 156 | 157 | $form->addValues($data_form); 158 | 159 | $this->setForm($form); 160 | 161 | return parent::_prepareForm(); 162 | } 163 | 164 | } 165 | -------------------------------------------------------------------------------- /Block/Adminhtml/Catalog/Grid.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2020-05-22 21:46:03 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Catalog; 14 | 15 | class Grid extends \Magento\Backend\Block\Widget\Grid\Extended 16 | { 17 | /** 18 | * @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory 19 | */ 20 | protected $_categoryCollectionFactory; 21 | 22 | 23 | /** 24 | * @var \Magento\Catalog\Model\Product\Attribute\Source\Status 25 | */ 26 | protected $_status; 27 | 28 | /** 29 | * @var \Magento\Catalog\Model\Product\Visibility 30 | */ 31 | protected $_visibility; 32 | 33 | /** 34 | * construct. 35 | * 36 | * @param \Magento\Backend\Block\Template\Context $context 37 | * @param \Magento\Backend\Helper\Data $backendHelper 38 | * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory 39 | * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $status 40 | * @param array $data 41 | */ 42 | public function __construct( 43 | \Magento\Backend\Block\Template\Context $context, 44 | \Magento\Backend\Helper\Data $backendHelper, 45 | \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollectionFactory, 46 | \Magento\Catalog\Model\Product\Attribute\Source\Status $status, 47 | 48 | array $data = [] 49 | ) { 50 | $this->_categoryCollectionFactory = $categoryCollectionFactory->create(); 51 | $this->_status = $status; 52 | parent::__construct($context, $backendHelper, $data); 53 | } 54 | 55 | protected function _construct() 56 | { 57 | parent::_construct(); 58 | $this->setId('categoryGrid'); 59 | $this->setDefaultSort('entity_id'); 60 | $this->setDefaultDir('ASC'); 61 | $this->setSaveParametersInSession(true); 62 | // $this->setPagerVisibility(false); 63 | $this->setUseAjax(true); 64 | } 65 | 66 | protected function _prepareCollection() 67 | { 68 | $collection = $this->_categoryCollectionFactory->addAttributeToSelect('*'); 69 | 70 | $this->setCollection($collection); 71 | 72 | return parent::_prepareCollection(); 73 | } 74 | 75 | public function getMultipleRows($item) 76 | { 77 | return []; 78 | } 79 | 80 | /** 81 | * @return $this 82 | */ 83 | protected function _prepareColumns() 84 | { 85 | $this->addColumn( 86 | 'entity_id', 87 | [ 88 | 'header' => __('ID'), 89 | 'type' => 'number', 90 | 'index' => 'entity_id', 91 | 'header_css_class' => 'col-id', 92 | 'column_css_class' => 'col-id' 93 | ] 94 | ); 95 | $this->addColumn( 96 | 'name', 97 | [ 98 | 'header' => __('Name'), 99 | 'index' => 'name', 100 | 'class' => 'xxx' 101 | ] 102 | ); 103 | 104 | $this->addColumn( 105 | 'edit', 106 | [ 107 | 'header' => __('Edit'), 108 | 'type' => 'action', 109 | 'getter' => 'getId', 110 | 'actions' => [ 111 | [ 112 | 'caption' => __('Edit'), 113 | 'url' => ['base' => '*/*/edit'], 114 | 'field' => 'category_id', 115 | ], 116 | ], 117 | 'filter' => false, 118 | 'sortable' => false, 119 | 'index' => 'stores', 120 | 'header_css_class' => 'col-action', 121 | 'column_css_class' => 'col-action', 122 | ] 123 | ); 124 | // $this->addExportType('*/*/exportCsv', __('CSV')); 125 | // $this->addExportType('*/*/exportXml', __('XML')); 126 | // $this->addExportType('*/*/exportExcel', __('Excel')); 127 | 128 | return parent::_prepareColumns(); 129 | } 130 | 131 | /** 132 | * get slider vailable option 133 | * 134 | * @return array 135 | */ 136 | 137 | /** 138 | * @return $this 139 | */ 140 | protected function _prepareMassaction() 141 | { 142 | // $this->setMassactionIdField('entity_id'); 143 | // $this->getMassactionBlock()->setFormFieldName('multitranslate'); 144 | 145 | // $this->getMassactionBlock()->addItem( 146 | // 'delete', 147 | // [ 148 | // 'label' => __('Delete'), 149 | // 'url' => $this->getUrl('multitranslate/*/massDelete'), 150 | // 'confirm' => __('Are you sure?'), 151 | // ] 152 | // ); 153 | 154 | // $statuses = $this->_status->getOptionArray(); 155 | 156 | // array_unshift($statuses, ['label' => '', 'value' => '']); 157 | // $this->getMassactionBlock()->addItem( 158 | // 'status', 159 | // [ 160 | // 'label' => __('Change status'), 161 | // 'url' => $this->getUrl('multitranslate/*/massStatus', ['_current' => true]), 162 | // 'additional' => [ 163 | // 'visibility' => [ 164 | // 'name' => 'status', 165 | // 'type' => 'select', 166 | // 'class' => 'required-entry', 167 | // 'label' => __('Status'), 168 | // 'values' => $statuses, 169 | // ], 170 | // ], 171 | // ] 172 | // ); 173 | 174 | return $this; 175 | } 176 | 177 | /** 178 | * @return string 179 | */ 180 | public function getGridUrl() 181 | { 182 | return $this->getUrl('*/*/grid', ['_current' => true]); 183 | } 184 | 185 | /** 186 | * get row url 187 | * @param object $row 188 | * @return string 189 | */ 190 | public function getRowUrl($row) 191 | { 192 | return $this->getUrl( 193 | '*/*/edit', 194 | ['category_id' => $row->getId()] 195 | ); 196 | } 197 | 198 | } 199 | -------------------------------------------------------------------------------- /Block/Adminhtml/Category.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 10:08:45 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml; 14 | 15 | class Category extends \Magento\Backend\Block\Widget\Grid\Container 16 | { 17 | /** 18 | * Constructor. 19 | */ 20 | protected function _construct() 21 | { 22 | $this->_controller = 'adminhtml_category'; 23 | $this->_blockGroup = 'Magepow_MultiTranslate'; 24 | $this->_headerText = __('Category'); 25 | parent::_construct(); 26 | $this->removeButton('add'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Block/Adminhtml/Category/Edit.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 10:13:58 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Category; 14 | 15 | class Edit extends \Magento\Backend\Block\Widget\Form\Container 16 | { 17 | 18 | /** 19 | * Core registry 20 | * 21 | * @var \Magento\Framework\Registry 22 | */ 23 | protected $_coreRegistry = null; 24 | 25 | /** 26 | * @param \Magento\Backend\Block\Widget\Context $context 27 | * @param \Magento\Framework\Registry $registry 28 | * @param array $data 29 | */ 30 | public function __construct( 31 | \Magento\Backend\Block\Widget\Context $context, 32 | \Magento\Framework\Registry $registry, 33 | array $data = [] 34 | ) { 35 | $this->_coreRegistry = $registry; 36 | parent::__construct($context, $data); 37 | } 38 | 39 | /** 40 | * _construct 41 | * @return void 42 | */ 43 | protected function _construct() 44 | { 45 | $this->_objectId = 'category_id'; 46 | $this->_blockGroup = 'Magepow_MultiTranslate'; 47 | $this->_controller = 'adminhtml_category'; 48 | 49 | parent::_construct(); 50 | 51 | $this->buttonList->update('delete', 'label', __('Delete')); 52 | $this->buttonList->remove('delete'); 53 | 54 | if ($this->_isAllowedAction('MultiTranslate_Category::save')) { 55 | $this->buttonList->update('save', 'label', __('Save')); 56 | $this->buttonList->add( 57 | 'saveandcontinue', 58 | [ 59 | 'label' => __('Save and Continue Edit'), 60 | 'class' => 'save', 61 | 'data_attribute' => [ 62 | 'mage-init' => [ 63 | 'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'], 64 | ], 65 | ] 66 | ], 67 | -100 68 | ); 69 | } 70 | // else { 71 | // $this->buttonList->remove('save'); 72 | // } 73 | 74 | // if ($this->_coreRegistry->registry('category')->getId()) { 75 | $this->buttonList->remove('reset'); 76 | // } 77 | } 78 | 79 | protected function _isAllowedAction($resourceId) 80 | { 81 | return $this->_authorization->isAllowed($resourceId); 82 | } 83 | 84 | /** 85 | * Retrieve the save and continue edit Url. 86 | * 87 | * @return string 88 | */ 89 | protected function getSaveAndContinueUrl() 90 | { 91 | return $this->getUrl( 92 | '*/*/save', 93 | [ 94 | '_current' => true, 95 | 'back' => 'edit', 96 | 'tab' => '{{tab_id}}', 97 | 'store' => $this->getRequest()->getParam('store'), 98 | 'category_id' => $this->getRequest()->getParam('category_id'), 99 | 'current_category_id' => $this->getRequest()->getParam('current_category_id'), 100 | ] 101 | ); 102 | } 103 | 104 | /** 105 | * Retrieve the save and continue edit Url. 106 | * 107 | * @return string 108 | */ 109 | protected function getSaveAndCloseWindowUrl() 110 | { 111 | return $this->getUrl( 112 | '*/*/save', 113 | [ 114 | '_current' => true, 115 | 'back' => 'edit', 116 | 'tab' => '{{tab_id}}', 117 | 'store' => $this->getRequest()->getParam('store'), 118 | 'category_id' => $this->getRequest()->getParam('category_id'), 119 | 'current_category_id' => $this->getRequest()->getParam('current_category_id'), 120 | 'saveandclose' => 1, 121 | ] 122 | ); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Block/Adminhtml/Category/Edit/Form.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 21:33:01 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Category\Edit; 14 | 15 | class Form extends \Magento\Backend\Block\Widget\Form\Generic 16 | { 17 | 18 | /** 19 | * @var \Magento\Framework\DataObjectFactory 20 | */ 21 | protected $_objectFactory; 22 | protected $_categoryFactory; 23 | protected $_wysiwygConfig; 24 | protected $_storeManager; 25 | 26 | public function __construct( 27 | \Magento\Backend\Block\Template\Context $context, 28 | \Magento\Framework\Registry $registry, 29 | \Magento\Framework\Data\FormFactory $formFactory, 30 | \Magento\Framework\DataObjectFactory $objectFactory, 31 | \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, 32 | \Magento\Catalog\Model\CategoryFactory $categoryFactory, 33 | array $data = [] 34 | ) { 35 | $this->_objectFactory = $objectFactory; 36 | $this->_categoryFactory = $categoryFactory; 37 | $this->_wysiwygConfig = $wysiwygConfig; 38 | $this->_storeManager = $context->getStoreManager(); 39 | parent::__construct($context, $registry, $formFactory, $data); 40 | } 41 | 42 | protected function _prepareForm() 43 | { 44 | $model = $this->_coreRegistry->registry('category'); 45 | 46 | /** @var \Magento\Framework\Data\Form $form */ 47 | $form = $this->_formFactory->create( 48 | array( 49 | 'data' => array( 50 | 'id' => 'edit_form', 51 | 'action' => $this->getUrl('*/*/save', ['store' => $this->getRequest()->getParam('store')]), 52 | 'method' => 'post', 53 | 'enctype' => 'multipart/form-data', 54 | ), 55 | ) 56 | ); 57 | $form->setUseContainer(true); 58 | $form->setHtmlIdPrefix('magic_'); 59 | 60 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Category Information')]); 61 | 62 | if ($model->getId()) { 63 | $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']); 64 | } 65 | 66 | $fieldset->addField('name', 'text', 67 | [ 68 | 'label' => __('Name (Default)'), 69 | 'title' => __('Name'), 70 | 'name' => 'name', 71 | 'required' => true, 72 | ] 73 | ); 74 | 75 | $fieldset->addField('use_default[name]', 'checkbox', 76 | [ 77 | 'label' => __('Use Default Value'), 78 | 'title' => __('Name'), 79 | 'name' => 'use_default[name]', 80 | 'required' => false, 81 | ] 82 | ); 83 | 84 | $fieldset->addField('description', 'editor', 85 | [ 86 | 'label' => __('Description (Default)'), 87 | 'title' => __('Description'), 88 | 'name' => 'description', 89 | 'config' => $this->_wysiwygConfig->getConfig(), 90 | 'wysiwyg' => true, 91 | 'required' => false, 92 | ] 93 | ); 94 | 95 | $fieldset->addField('use_default[description]', 'checkbox', 96 | [ 97 | 'label' => __('Use Default Value'), 98 | 'title' => __('Name'), 99 | 'name' => 'use_default[description]', 100 | 'required' => false, 101 | ] 102 | ); 103 | 104 | $category = $this->_categoryFactory->create(); 105 | $stores = $this->_storeManager->getStores(); 106 | $data = $model->getData(); 107 | $data_form = $data; 108 | foreach ($stores as $store) { 109 | $store_id = $store->getId(); 110 | $store_name = $store->getName(); 111 | $group_name = $this->_storeManager->getStore($store_id)->getGroup()->getName(); 112 | $category_id = $model->getId(); 113 | $_category = $category->setStoreId($store_id)->load($category_id); 114 | 115 | $nameChecked = !$_category->getExistsStoreValueFlag('name'); 116 | $descriptionChecked = !$_category->getExistsStoreValueFlag('description'); 117 | 118 | $_data = $_category->getData(); 119 | foreach ($_data as $key => $value) { 120 | $key = $key . '_' . $store_id; 121 | $data_form[$key] = $value; 122 | } 123 | 124 | $name = $fieldset->addField("name_$store_id", 'text', 125 | [ 126 | 'label' => __("Name ($group_name - $store_name)"), 127 | 'title' => __("Name ($store_name)"), 128 | 'name' => "name_$store_id", 129 | 'required' => true, 130 | ] 131 | ); 132 | 133 | $name_default = $fieldset->addField("use_default[name_$store_id]", 'checkbox', 134 | [ 135 | 'label' => __('Use Default Value'), 136 | 'title' => __('Name'), 137 | 'name' => "use_default[name_$store_id]", 138 | 'value' => 1, 139 | 'checked' => $nameChecked, 140 | 'required' => false, 141 | ] 142 | ); 143 | 144 | $name_default->setAfterElementHtml( 145 | '' 166 | ); 167 | 168 | $fieldset->addField("description_$store_id", 'editor', 169 | [ 170 | 'label' => __("Description ($store_name)"), 171 | 'title' => __("Description ($store_name)"), 172 | 'name' => "description_$store_id", 173 | 'config' => $this->_wysiwygConfig->getConfig(), 174 | 'wysiwyg' => true, 175 | 'required' => false, 176 | ] 177 | ); 178 | 179 | $fieldset->addField("use_default[description_$store_id]", 'checkbox', 180 | [ 181 | 'label' => __('Use Default Value'), 182 | 'title' => __('Description'), 183 | 'name' => "use_default[description_$store_id]", 184 | 'value' => 1, 185 | 'checked' => $descriptionChecked, 186 | 'required' => false, 187 | ] 188 | ); 189 | 190 | } 191 | 192 | $form->addValues($data_form); 193 | 194 | $this->setForm($form); 195 | 196 | return parent::_prepareForm(); 197 | } 198 | 199 | } 200 | -------------------------------------------------------------------------------- /Block/Adminhtml/Category/Grid.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2020-05-22 21:26:10 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Category; 14 | 15 | class Grid extends \Magento\Backend\Block\Widget\Grid\Extended 16 | { 17 | 18 | /** 19 | * @var Category 20 | */ 21 | protected $_categoryInstance; 22 | 23 | /** 24 | * @var \Magento\Catalog\Model\Product\Type 25 | */ 26 | protected $_type; 27 | 28 | /** 29 | * @var \Magento\Catalog\Model\Product\Attribute\Source\Status 30 | */ 31 | protected $_status; 32 | 33 | /** 34 | * @var \Magento\Catalog\Model\Product\Visibility 35 | */ 36 | protected $_visibility; 37 | 38 | /** 39 | * construct. 40 | * 41 | * @param \Magento\Backend\Block\Template\Context $context 42 | * @param \Magento\Backend\Helper\Data $backendHelper 43 | * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory 44 | * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $status 45 | * @param array $data 46 | */ 47 | public function __construct( 48 | \Magento\Backend\Block\Template\Context $context, 49 | \Magento\Backend\Helper\Data $backendHelper, 50 | \Magento\Catalog\Model\CategoryFactory $categoryFactory, 51 | \Magento\Catalog\Model\Product\Attribute\Source\Status $status, 52 | 53 | array $data = [] 54 | ) { 55 | $this->_categoryInstance = $categoryFactory->create(); 56 | $this->_status = $status; 57 | parent::__construct($context, $backendHelper, $data); 58 | } 59 | 60 | protected function _construct() 61 | { 62 | parent::_construct(); 63 | $this->setId('categoryGrid'); 64 | $this->setDefaultSort('entity_id'); 65 | $this->setDefaultDir('ASC'); 66 | $this->setSaveParametersInSession(true); 67 | // $this->setPagerVisibility(false); 68 | $this->setUseAjax(true); 69 | } 70 | 71 | protected function _prepareCollection() 72 | { 73 | 74 | $collection = $this->_categoryInstance->getCollection() 75 | ->addAttributeToSelect(array('entity_id','name')); 76 | 77 | // foreach ($collection as $key => $item) { 78 | // $collection->removeItemByKey($key);// Remove original item from collection 79 | // $item->setData('children', array()); 80 | // $collection->addItem($item);// Add modified item to collection 81 | // } 82 | $this->setCollection($collection); 83 | 84 | return parent::_prepareCollection(); 85 | } 86 | 87 | public function getMultipleRows($item) 88 | { 89 | // Fix error conflict with method getChildren of Extended and Category 90 | return []; 91 | } 92 | 93 | /** 94 | * @return $this 95 | */ 96 | protected function _prepareColumns() 97 | { 98 | $this->addColumn( 99 | 'entity_id', 100 | [ 101 | 'header' => __('ID'), 102 | 'type' => 'number', 103 | 'index' => 'entity_id', 104 | 'header_css_class' => 'col-id', 105 | 'column_css_class' => 'col-id' 106 | ] 107 | ); 108 | $this->addColumn( 109 | 'name', 110 | [ 111 | 'header' => __('Name'), 112 | 'index' => 'name', 113 | 'class' => 'xxx' 114 | ] 115 | ); 116 | 117 | $this->addColumn( 118 | 'edit', 119 | [ 120 | 'header' => __('Edit'), 121 | 'type' => 'action', 122 | 'getter' => 'getId', 123 | 'actions' => [ 124 | [ 125 | 'caption' => __('Edit'), 126 | 'url' => ['base' => '*/*/edit'], 127 | 'field' => 'category_id', 128 | ], 129 | ], 130 | 'filter' => false, 131 | 'sortable' => false, 132 | 'index' => 'stores', 133 | 'header_css_class' => 'col-action', 134 | 'column_css_class' => 'col-action', 135 | ] 136 | ); 137 | // $this->addExportType('*/*/exportCsv', __('CSV')); 138 | // $this->addExportType('*/*/exportXml', __('XML')); 139 | // $this->addExportType('*/*/exportExcel', __('Excel')); 140 | 141 | return parent::_prepareColumns(); 142 | } 143 | 144 | /** 145 | * get slider vailable option 146 | * 147 | * @return array 148 | */ 149 | 150 | /** 151 | * @return $this 152 | */ 153 | protected function _prepareMassaction() 154 | { 155 | // $this->setMassactionIdField('entity_id'); 156 | // $this->getMassactionBlock()->setFormFieldName('multitranslate'); 157 | 158 | // $this->getMassactionBlock()->addItem( 159 | // 'delete', 160 | // [ 161 | // 'label' => __('Delete'), 162 | // 'url' => $this->getUrl('multitranslate/*/massDelete'), 163 | // 'confirm' => __('Are you sure?'), 164 | // ] 165 | // ); 166 | 167 | // $statuses = $this->_status->getOptionArray(); 168 | 169 | // array_unshift($statuses, ['label' => '', 'value' => '']); 170 | // $this->getMassactionBlock()->addItem( 171 | // 'status', 172 | // [ 173 | // 'label' => __('Change status'), 174 | // 'url' => $this->getUrl('multitranslate/*/massStatus', ['_current' => true]), 175 | // 'additional' => [ 176 | // 'visibility' => [ 177 | // 'name' => 'status', 178 | // 'type' => 'select', 179 | // 'class' => 'required-entry', 180 | // 'label' => __('Status'), 181 | // 'values' => $statuses, 182 | // ], 183 | // ], 184 | // ] 185 | // ); 186 | 187 | return $this; 188 | } 189 | 190 | /** 191 | * @return string 192 | */ 193 | public function getGridUrl() 194 | { 195 | return $this->getUrl('*/*/grid', ['_current' => true]); 196 | } 197 | 198 | /** 199 | * get row url 200 | * @param object $row 201 | * @return string 202 | */ 203 | public function getRowUrl($row) 204 | { 205 | return $this->getUrl( 206 | '*/*/edit', 207 | ['category_id' => $row->getId()] 208 | ); 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /Block/Adminhtml/Product.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-21 12:33:10 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml; 14 | 15 | class Product extends \Magento\Backend\Block\Widget\Grid\Container 16 | { 17 | /** 18 | * Constructor. 19 | */ 20 | protected function _construct() 21 | { 22 | $this->_controller = 'adminhtml_product'; 23 | $this->_blockGroup = 'Magepow_MultiTranslate'; 24 | $this->_headerText = __('Product'); 25 | parent::_construct(); 26 | $this->removeButton('add'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Block/Adminhtml/Product/Edit.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-21 20:50:14 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Product; 14 | 15 | class Edit extends \Magento\Backend\Block\Widget\Form\Container 16 | { 17 | 18 | /** 19 | * Core registry 20 | * 21 | * @var \Magento\Framework\Registry 22 | */ 23 | protected $_coreRegistry = null; 24 | 25 | /** 26 | * @param \Magento\Backend\Block\Widget\Context $context 27 | * @param \Magento\Framework\Registry $registry 28 | * @param array $data 29 | */ 30 | public function __construct( 31 | \Magento\Backend\Block\Widget\Context $context, 32 | \Magento\Framework\Registry $registry, 33 | array $data = [] 34 | ) { 35 | $this->_coreRegistry = $registry; 36 | parent::__construct($context, $data); 37 | } 38 | 39 | /** 40 | * _construct 41 | * @return void 42 | */ 43 | protected function _construct() 44 | { 45 | $this->_objectId = 'product_id'; 46 | $this->_blockGroup = 'Magepow_MultiTranslate'; 47 | $this->_controller = 'adminhtml_product'; 48 | 49 | parent::_construct(); 50 | 51 | $this->buttonList->update('delete', 'label', __('Delete')); 52 | $this->buttonList->remove('delete'); 53 | 54 | if ($this->_isAllowedAction('MultiTranslate_Product::save')) { 55 | $this->buttonList->update('save', 'label', __('Save')); 56 | $this->buttonList->add( 57 | 'saveandcontinue', 58 | [ 59 | 'label' => __('Save and Continue Edit'), 60 | 'class' => 'save', 61 | 'data_attribute' => [ 62 | 'mage-init' => [ 63 | 'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'], 64 | ], 65 | ] 66 | ], 67 | -100 68 | ); 69 | } 70 | // else { 71 | // $this->buttonList->remove('save'); 72 | // } 73 | 74 | // if ($this->_coreRegistry->registry('product')->getId()) { 75 | $this->buttonList->remove('reset'); 76 | // } 77 | } 78 | 79 | protected function _isAllowedAction($resourceId) 80 | { 81 | return $this->_authorization->isAllowed($resourceId); 82 | } 83 | 84 | /** 85 | * Retrieve the save and continue edit Url. 86 | * 87 | * @return string 88 | */ 89 | protected function getSaveAndContinueUrl() 90 | { 91 | return $this->getUrl( 92 | '*/*/save', 93 | [ 94 | '_current' => true, 95 | 'back' => 'edit', 96 | 'tab' => '{{tab_id}}', 97 | 'store' => $this->getRequest()->getParam('store'), 98 | 'product_id' => $this->getRequest()->getParam('product_id'), 99 | 'current_product_id' => $this->getRequest()->getParam('current_product_id'), 100 | ] 101 | ); 102 | } 103 | 104 | /** 105 | * Retrieve the save and continue edit Url. 106 | * 107 | * @return string 108 | */ 109 | protected function getSaveAndCloseWindowUrl() 110 | { 111 | return $this->getUrl( 112 | '*/*/save', 113 | [ 114 | '_current' => true, 115 | 'back' => 'edit', 116 | 'tab' => '{{tab_id}}', 117 | 'store' => $this->getRequest()->getParam('store'), 118 | 'product_id' => $this->getRequest()->getParam('product_id'), 119 | 'current_product_id' => $this->getRequest()->getParam('current_product_id'), 120 | 'saveandclose' => 1, 121 | ] 122 | ); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Block/Adminhtml/Product/Edit/Form.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2020-05-22 11:40:16 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Product\Edit; 14 | 15 | class Form extends \Magento\Backend\Block\Widget\Form\Generic 16 | { 17 | 18 | /** 19 | * @var \Magento\Framework\DataObjectFactory 20 | */ 21 | protected $_objectFactory; 22 | protected $_productFactory; 23 | protected $_wysiwygConfig; 24 | protected $_storeManager; 25 | 26 | public function __construct( 27 | \Magento\Backend\Block\Template\Context $context, 28 | \Magento\Framework\Registry $registry, 29 | \Magento\Framework\Data\FormFactory $formFactory, 30 | \Magento\Framework\DataObjectFactory $objectFactory, 31 | \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, 32 | \Magento\Catalog\Model\ProductFactory $productFactory, 33 | array $data = [] 34 | ) { 35 | $this->_objectFactory = $objectFactory; 36 | $this->_productFactory = $productFactory; 37 | $this->_wysiwygConfig = $wysiwygConfig; 38 | $this->_storeManager = $context->getStoreManager(); 39 | parent::__construct($context, $registry, $formFactory, $data); 40 | } 41 | 42 | protected function _prepareForm() 43 | { 44 | $model = $this->_coreRegistry->registry('product'); 45 | 46 | /** @var \Magento\Framework\Data\Form $form */ 47 | $form = $this->_formFactory->create( 48 | array( 49 | 'data' => array( 50 | 'id' => 'edit_form', 51 | 'action' => $this->getUrl('*/*/save', ['store' => $this->getRequest()->getParam('store')]), 52 | 'method' => 'post', 53 | 'enctype' => 'multipart/form-data', 54 | ), 55 | ) 56 | ); 57 | $form->setUseContainer(true); 58 | $form->setHtmlIdPrefix('magic_'); 59 | 60 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Product Information')]); 61 | 62 | if ($model->getId()) { 63 | $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']); 64 | } 65 | 66 | $name = $fieldset->addField('name', 'text', 67 | [ 68 | 'label' => __('Name (Default)'), 69 | 'title' => __('Name'), 70 | 'name' => 'name', 71 | 'required' => true, 72 | ] 73 | ); 74 | 75 | $name->setAfterElementHtml( 76 | '' 86 | ); 87 | 88 | 89 | // $fieldset->addField('use_default[name]', 'checkbox', 90 | // [ 91 | // 'label' => __('Use Default Value'), 92 | // 'title' => __('Name'), 93 | // 'name' => 'use_default[name]', 94 | // 'required' => false, 95 | // ] 96 | // ); 97 | 98 | $fieldset->addField('description', 'editor', 99 | [ 100 | 'label' => __('Description (Default)'), 101 | 'title' => __('Description'), 102 | 'name' => 'description', 103 | 'config' => $this->_wysiwygConfig->getConfig(), 104 | 'wysiwyg' => true, 105 | 'required' => false, 106 | ] 107 | ); 108 | 109 | // $fieldset->addField('use_default[description]', 'checkbox', 110 | // [ 111 | // 'label' => __('Use Default Value'), 112 | // 'title' => __('Name'), 113 | // 'name' => 'use_default[description]', 114 | // 'required' => false, 115 | // ] 116 | // ); 117 | 118 | $fieldset->addField('short_description', 'editor', 119 | [ 120 | 'label' => __('Short description (Default)'), 121 | 'title' => __('Short description'), 122 | 'name' => 'short_description', 123 | 'config' => $this->_wysiwygConfig->getConfig(), 124 | 'wysiwyg' => true, 125 | 'required' => false, 126 | ] 127 | ); 128 | 129 | // $fieldset->addField('use_default[short_description]', 'checkbox', 130 | // [ 131 | // 'label' => __('Use Default Value'), 132 | // 'title' => __('Name'), 133 | // 'name' => 'use_default[short_description]', 134 | // 'required' => false, 135 | // ] 136 | // ); 137 | 138 | $product = $this->_productFactory->create(); 139 | $stores = $this->_storeManager->getStores(); 140 | $data = $model->getData(); 141 | $data_form = $data; 142 | foreach ($stores as $store) { 143 | $storeId = $store->getId(); 144 | $store_name = $store->getName(); 145 | $group_name = $this->_storeManager->getStore($storeId)->getGroup()->getName(); 146 | $productId = $model->getId(); 147 | $_product = $product->setStoreId($storeId)->load($productId); 148 | 149 | $nameChecked = !$_product->getExistsStoreValueFlag('name'); 150 | $descriptionChecked = !$_product->getExistsStoreValueFlag('description'); 151 | $short_descriptionChecked = !$_product->getExistsStoreValueFlag('short_description'); 152 | 153 | $_data = $_product->getData(); 154 | foreach ($_data as $key => $value) { 155 | $key = $key . '_' . $storeId; 156 | $data_form[$key] = $value; 157 | } 158 | 159 | $name = $fieldset->addField("name_$storeId", 'text', 160 | [ 161 | 'label' => __("Name ($group_name - $store_name)"), 162 | 'title' => __("Name ($store_name)"), 163 | 'name' => "name_$storeId", 164 | 'required' => true, 165 | ] 166 | ); 167 | 168 | $name_default = $fieldset->addField("use_default[name_$storeId]", 'checkbox', 169 | [ 170 | 'label' => __('Use Default Value'), 171 | 'title' => __('Name'), 172 | 'name' => "use_default[name_$storeId]", 173 | 'value' => 1, 174 | 'checked' => $nameChecked, 175 | 'required' => false, 176 | ] 177 | ); 178 | 179 | $name_default->setAfterElementHtml( 180 | '' 203 | ); 204 | 205 | $fieldset->addField("description_$storeId", 'editor', 206 | [ 207 | 'label' => __("Description ($store_name)"), 208 | 'title' => __("Description ($store_name)"), 209 | 'name' => "description_$storeId", 210 | 'config' => $this->_wysiwygConfig->getConfig(), 211 | 'wysiwyg' => true, 212 | 'required' => false, 213 | ] 214 | ); 215 | 216 | $fieldset->addField("short_description_$storeId", 'editor', 217 | [ 218 | 'label' => __("Short Description ($store_name)"), 219 | 'title' => __("Short Description ($store_name)"), 220 | 'name' => "short_description_$storeId", 221 | 'config' => $this->_wysiwygConfig->getConfig(), 222 | 'wysiwyg' => true, 223 | 'required' => false, 224 | ] 225 | ); 226 | 227 | $fieldset->addField("use_default[description_$storeId]", 'checkbox', 228 | [ 229 | 'label' => __('Use Default Value'), 230 | 'title' => __('Description'), 231 | 'name' => "use_default[description_$storeId]", 232 | 'value' => 1, 233 | 'checked' => $descriptionChecked, 234 | 'required' => false, 235 | ] 236 | ); 237 | 238 | $fieldset->addField("use_default[short_description_$storeId]", 'checkbox', 239 | [ 240 | 'label' => __('Use Default Value'), 241 | 'title' => __('Short Description'), 242 | 'name' => "use_default[short_description_$storeId]", 243 | 'value' => 1, 244 | 'checked' => $short_descriptionChecked, 245 | 'required' => false, 246 | ] 247 | ); 248 | 249 | } 250 | 251 | $form->addValues($data_form); 252 | 253 | $this->setForm($form); 254 | 255 | return parent::_prepareForm(); 256 | } 257 | 258 | } 259 | -------------------------------------------------------------------------------- /Block/Adminhtml/Product/Edit/Form.php_orginal: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-04-12 10:58:16 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Product\Edit; 14 | 15 | class Form extends \Magento\Backend\Block\Widget\Form\Generic 16 | { 17 | 18 | /** 19 | * @var \Magento\Framework\DataObjectFactory 20 | */ 21 | protected $_objectFactory; 22 | protected $_productFactory; 23 | protected $_wysiwygConfig; 24 | protected $_storeManager; 25 | 26 | public function __construct( 27 | \Magento\Backend\Block\Template\Context $context, 28 | \Magento\Framework\Registry $registry, 29 | \Magento\Framework\Data\FormFactory $formFactory, 30 | \Magento\Framework\DataObjectFactory $objectFactory, 31 | \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, 32 | \Magento\Catalog\Model\ProductFactory $productFactory, 33 | array $data = [] 34 | ) { 35 | $this->_objectFactory = $objectFactory; 36 | $this->_productFactory = $productFactory; 37 | $this->_wysiwygConfig = $wysiwygConfig; 38 | $this->_storeManager = $context->getStoreManager(); 39 | parent::__construct($context, $registry, $formFactory, $data); 40 | } 41 | 42 | protected function _prepareForm() 43 | { 44 | $model = $this->_coreRegistry->registry('product'); 45 | 46 | /** @var \Magento\Framework\Data\Form $form */ 47 | $form = $this->_formFactory->create( 48 | array( 49 | 'data' => array( 50 | 'id' => 'edit_form', 51 | 'action' => $this->getUrl('*/*/save', ['store' => $this->getRequest()->getParam('store')]), 52 | 'method' => 'post', 53 | 'enctype' => 'multipart/form-data', 54 | ), 55 | ) 56 | ); 57 | $form->setUseContainer(true); 58 | $form->setHtmlIdPrefix('magic_'); 59 | 60 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Product Information')]); 61 | 62 | if ($model->getId()) { 63 | $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']); 64 | } 65 | 66 | $fieldset->addField('name', 'text', 67 | [ 68 | 'label' => __('Name (Default)'), 69 | 'title' => __('Name'), 70 | 'name' => 'name', 71 | 'required' => true, 72 | ] 73 | ); 74 | 75 | // $fieldset->addField('use_default[name]', 'checkbox', 76 | // [ 77 | // 'label' => __('Default Y/N'), 78 | // 'title' => __('Name'), 79 | // 'name' => 'use_default[name]', 80 | // 'required' => false, 81 | // ] 82 | // ); 83 | 84 | $fieldset->addField('description', 'editor', 85 | [ 86 | 'label' => __('Description (Default)'), 87 | 'title' => __('Description'), 88 | 'name' => 'description', 89 | 'config' => $this->_wysiwygConfig->getConfig(), 90 | 'wysiwyg' => true, 91 | 'required' => false, 92 | ] 93 | ); 94 | 95 | // $fieldset->addField('use_default[description]', 'checkbox', 96 | // [ 97 | // 'label' => __('Default Y/N'), 98 | // 'title' => __('Name'), 99 | // 'name' => 'use_default[description]', 100 | // 'required' => false, 101 | // ] 102 | // ); 103 | 104 | $fieldset->addField('short_description', 'editor', 105 | [ 106 | 'label' => __('Short description (Default)'), 107 | 'title' => __('Short description'), 108 | 'name' => 'short_description', 109 | 'config' => $this->_wysiwygConfig->getConfig(), 110 | 'wysiwyg' => true, 111 | 'required' => false, 112 | ] 113 | ); 114 | 115 | // $fieldset->addField('use_default[short_description]', 'checkbox', 116 | // [ 117 | // 'label' => __('Default Y/N'), 118 | // 'title' => __('Name'), 119 | // 'name' => 'use_default[short_description]', 120 | // 'required' => false, 121 | // ] 122 | // ); 123 | 124 | $product = $this->_productFactory->create(); 125 | $stores = $this->_storeManager->getStores(); 126 | $data = $model->getData(); 127 | $data_form = $data; 128 | foreach ($stores as $store) { 129 | $store_id = $store->getId(); 130 | $store_name = $store->getName(); 131 | $group_name = $this->_storeManager->getStore($store_id)->getGroup()->getName(); 132 | $product_id = $model->getId(); 133 | $_product = $product->setStoreId($store_id)->load($product_id); 134 | 135 | $nameChecked = !$_product->getExistsStoreValueFlag('name'); 136 | $descriptionChecked = !$_product->getExistsStoreValueFlag('description'); 137 | $short_descriptionChecked = !$_product->getExistsStoreValueFlag('short_description'); 138 | 139 | $_data = $_product->getData(); 140 | foreach ($_data as $key => $value) { 141 | $key = $key . '_' . $store_id; 142 | $data_form[$key] = $value; 143 | } 144 | 145 | $name = $fieldset->addField("name_$store_id", 'text', 146 | [ 147 | 'label' => __("Name ($group_name - $store_name)"), 148 | 'title' => __("Name ($store_name)"), 149 | 'name' => "name_$store_id", 150 | 'required' => true, 151 | ] 152 | ); 153 | 154 | $name_default = $fieldset->addField("use_default[name_$store_id]", 'checkbox', 155 | [ 156 | 'label' => __('Default Y/N'), 157 | 'title' => __('Name'), 158 | 'name' => "use_default[name_$store_id]", 159 | 'value' => 1, 160 | 'checked' => $nameChecked, 161 | 'required' => false, 162 | ] 163 | ); 164 | 165 | $name_default->setAfterElementHtml( 166 | '' 189 | ); 190 | 191 | $fieldset->addField("description_$store_id", 'editor', 192 | [ 193 | 'label' => __("Description ($store_name)"), 194 | 'title' => __("Description ($store_name)"), 195 | 'name' => "description_$store_id", 196 | 'config' => $this->_wysiwygConfig->getConfig(), 197 | 'wysiwyg' => true, 198 | 'required' => false, 199 | ] 200 | ); 201 | 202 | $fieldset->addField("use_default[description_$store_id]", 'checkbox', 203 | [ 204 | 'label' => __('Default Y/N'), 205 | 'title' => __('Description'), 206 | 'name' => "use_default[description_$store_id]", 207 | 'value' => 1, 208 | 'checked' => $descriptionChecked, 209 | 'required' => false, 210 | ] 211 | ); 212 | 213 | $fieldset->addField("short_description_$store_id", 'editor', 214 | [ 215 | 'label' => __("Short Description ($store_name)"), 216 | 'title' => __("Short Description ($store_name)"), 217 | 'name' => "short_description_$store_id", 218 | 'config' => $this->_wysiwygConfig->getConfig(), 219 | 'wysiwyg' => true, 220 | 'required' => false, 221 | ] 222 | ); 223 | 224 | $fieldset->addField("use_default[short_description_$store_id]", 'checkbox', 225 | [ 226 | 'label' => __('Default Y/N'), 227 | 'title' => __('Short Description'), 228 | 'name' => "use_default[short_description_$store_id]", 229 | 'value' => 1, 230 | 'checked' => $short_descriptionChecked, 231 | 'required' => false, 232 | ] 233 | ); 234 | 235 | } 236 | 237 | $form->addValues($data_form); 238 | 239 | $this->setForm($form); 240 | 241 | return parent::_prepareForm(); 242 | } 243 | 244 | } 245 | -------------------------------------------------------------------------------- /Block/Adminhtml/Product/Grid.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-21 15:59:13 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Block\Adminhtml\Product; 14 | 15 | class Grid extends \Magento\Backend\Block\Widget\Grid\Extended 16 | { 17 | /** 18 | * @var \Magento\Catalog\Model\ProductFactory 19 | */ 20 | protected $_productFactory; 21 | 22 | /** 23 | * @var \Magento\Catalog\Model\Product\Type 24 | */ 25 | protected $_type; 26 | 27 | /** 28 | * @var \Magento\Catalog\Model\Product\Attribute\Source\Status 29 | */ 30 | protected $_status; 31 | 32 | /** 33 | * @var \Magento\Catalog\Model\Product\Visibility 34 | */ 35 | protected $_visibility; 36 | 37 | /** 38 | * construct. 39 | * 40 | * @param \Magento\Backend\Block\Template\Context $context 41 | * @param \Magento\Backend\Helper\Data $backendHelper 42 | * @param \Magento\Catalog\Model\ProductFactory $productFactory 43 | * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $status 44 | * @param array $data 45 | */ 46 | public function __construct( 47 | \Magento\Backend\Block\Template\Context $context, 48 | \Magento\Backend\Helper\Data $backendHelper, 49 | \Magento\Catalog\Model\ProductFactory $productFactory, 50 | \Magento\Catalog\Model\Product\Attribute\Source\Status $status, 51 | 52 | array $data = [] 53 | ) { 54 | $this->_productFactory = $productFactory; 55 | $this->_status = $status; 56 | parent::__construct($context, $backendHelper, $data); 57 | } 58 | 59 | protected function _construct() 60 | { 61 | parent::_construct(); 62 | $this->setId('productGrid'); 63 | $this->setDefaultSort('entity_id'); 64 | $this->setDefaultDir('ASC'); 65 | $this->setSaveParametersInSession(true); 66 | $this->setUseAjax(true); 67 | } 68 | 69 | protected function _prepareCollection() 70 | { 71 | 72 | $collection = $this->_productFactory->create()->getCollection() 73 | ->addAttributeToSelect( 74 | 'sku' 75 | )->addAttributeToSelect( 76 | 'name' 77 | ); 78 | $this->setCollection($collection); 79 | 80 | return parent::_prepareCollection(); 81 | } 82 | 83 | /** 84 | * @return $this 85 | */ 86 | protected function _prepareColumns() 87 | { 88 | $this->addColumn( 89 | 'entity_id', 90 | [ 91 | 'header' => __('ID'), 92 | 'type' => 'number', 93 | 'index' => 'entity_id', 94 | 'header_css_class' => 'col-id', 95 | 'column_css_class' => 'col-id' 96 | ] 97 | ); 98 | $this->addColumn( 99 | 'name', 100 | [ 101 | 'header' => __('Name'), 102 | 'index' => 'name', 103 | 'class' => 'xxx' 104 | ] 105 | ); 106 | 107 | $this->addColumn( 108 | 'sku', 109 | [ 110 | 'header' => __('Sku'), 111 | 'index' => 'sku', 112 | 'class' => 'xxx' 113 | ] 114 | ); 115 | 116 | $this->addColumn( 117 | 'edit', 118 | [ 119 | 'header' => __('Edit'), 120 | 'type' => 'action', 121 | 'getter' => 'getId', 122 | 'actions' => [ 123 | [ 124 | 'caption' => __('Edit'), 125 | 'url' => ['base' => '*/*/edit'], 126 | 'field' => 'product_id', 127 | ], 128 | ], 129 | 'filter' => false, 130 | 'sortable' => false, 131 | 'index' => 'stores', 132 | 'header_css_class' => 'col-action', 133 | 'column_css_class' => 'col-action', 134 | ] 135 | ); 136 | // $this->addExportType('*/*/exportCsv', __('CSV')); 137 | // $this->addExportType('*/*/exportXml', __('XML')); 138 | // $this->addExportType('*/*/exportExcel', __('Excel')); 139 | 140 | return parent::_prepareColumns(); 141 | } 142 | 143 | /** 144 | * get slider vailable option 145 | * 146 | * @return array 147 | */ 148 | 149 | /** 150 | * @return $this 151 | */ 152 | protected function _prepareMassaction() 153 | { 154 | // $this->setMassactionIdField('entity_id'); 155 | // $this->getMassactionBlock()->setFormFieldName('multitranslate'); 156 | 157 | // $this->getMassactionBlock()->addItem( 158 | // 'delete', 159 | // [ 160 | // 'label' => __('Delete'), 161 | // 'url' => $this->getUrl('multitranslate/*/massDelete'), 162 | // 'confirm' => __('Are you sure?'), 163 | // ] 164 | // ); 165 | 166 | // $statuses = $this->_status->getOptionArray(); 167 | 168 | // array_unshift($statuses, ['label' => '', 'value' => '']); 169 | // $this->getMassactionBlock()->addItem( 170 | // 'status', 171 | // [ 172 | // 'label' => __('Change status'), 173 | // 'url' => $this->getUrl('multitranslate/*/massStatus', ['_current' => true]), 174 | // 'additional' => [ 175 | // 'visibility' => [ 176 | // 'name' => 'status', 177 | // 'type' => 'select', 178 | // 'class' => 'required-entry', 179 | // 'label' => __('Status'), 180 | // 'values' => $statuses, 181 | // ], 182 | // ], 183 | // ] 184 | // ); 185 | 186 | return $this; 187 | } 188 | 189 | /** 190 | * @return string 191 | */ 192 | public function getGridUrl() 193 | { 194 | return $this->getUrl('*/*/grid', ['_current' => true]); 195 | } 196 | 197 | /** 198 | * get row url 199 | * @param object $row 200 | * @return string 201 | */ 202 | public function getRowUrl($row) 203 | { 204 | return $this->getUrl( 205 | '*/*/edit', 206 | ['product_id' => $row->getId()] 207 | ); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Action.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-21 14:26:05 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml; 14 | 15 | abstract class Action extends \Magento\Backend\App\Action 16 | { 17 | 18 | /** 19 | * @var \Magento\Backend\Helper\Js 20 | */ 21 | protected $_jsHelper; 22 | 23 | /** 24 | * @var \Magento\Store\Model\StoreManagerInterface 25 | */ 26 | protected $_storeManager; 27 | 28 | /** 29 | * Core store config 30 | * 31 | * @var \Magento\Framework\App\Config\ScopeConfigInterface 32 | */ 33 | protected $_scopeConfig; 34 | 35 | /** 36 | * @var \Magento\Backend\Model\View\Result\ForwardFactory 37 | */ 38 | protected $_resultForwardFactory; 39 | 40 | /** 41 | * @var \Magento\Framework\View\Result\LayoutFactory 42 | */ 43 | protected $_resultLayoutFactory; 44 | 45 | /** 46 | * A factory that knows how to create a "page" result 47 | * Requires an instance of controller action in order to impose page type, 48 | * which is by convention is determined from the controller action class. 49 | * 50 | * @var \Magento\Framework\View\Result\PageFactory 51 | */ 52 | protected $_resultPageFactory; 53 | 54 | /** 55 | * @var \Magento\Backend\Model\View\Result\RedirectFactory 56 | */ 57 | protected $_resultRedirectFactory; 58 | 59 | /** 60 | * Registry object. 61 | * 62 | * @var \Magento\Framework\Registry 63 | */ 64 | protected $_coreRegistry; 65 | 66 | /** 67 | * File Factory. 68 | * 69 | * @var \Magento\Framework\App\Response\Http\FileFactory 70 | */ 71 | protected $_fileFactory; 72 | 73 | /** 74 | * @var \Magento\Framework\Filesystem 75 | */ 76 | protected $_filesystem; 77 | 78 | public function __construct( 79 | \Magento\Backend\App\Action\Context $context, 80 | \Magento\Framework\Registry $coreRegistry, 81 | \Magento\Framework\App\Response\Http\FileFactory $fileFactory, 82 | \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, 83 | \Magento\Framework\View\Result\PageFactory $resultPageFactory, 84 | \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, 85 | \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, 86 | \Magento\Store\Model\StoreManagerInterface $storeManager, 87 | \Magento\Backend\Helper\Js $jsHelper, 88 | \Magento\Framework\Filesystem $filesystem 89 | ) { 90 | parent::__construct($context); 91 | $this->_coreRegistry = $coreRegistry; 92 | $this->_fileFactory = $fileFactory; 93 | $this->_storeManager = $storeManager; 94 | $this->_scopeConfig = $scopeConfig; 95 | $this->_jsHelper = $jsHelper; 96 | 97 | $this->_resultPageFactory = $resultPageFactory; 98 | $this->_resultLayoutFactory = $resultLayoutFactory; 99 | $this->_resultForwardFactory = $resultForwardFactory; 100 | $this->_resultRedirectFactory = $context->getResultRedirectFactory(); 101 | $this->_filesystem = $filesystem; 102 | } 103 | 104 | protected function _isAllowed() 105 | { 106 | $namespace = (new \ReflectionObject($this))->getNamespaceName(); 107 | $string = strtolower(str_replace(__NAMESPACE__ . '\\','', $namespace)); 108 | $action = explode('\\', $string); 109 | $action = array_shift($action); 110 | return $this->_authorization->isAllowed("Magepow_MultiTranslate::multitranslate_$action"); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Catalog.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 23:00:41 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml; 14 | 15 | abstract class Catalog extends \Magento\Backend\App\Action 16 | { 17 | /** 18 | * @var \Magento\Backend\Helper\Js 19 | */ 20 | protected $_jsHelper; 21 | 22 | /** 23 | * @var \Magento\Store\Model\StoreManagerInterface 24 | */ 25 | protected $_storeManager; 26 | 27 | /** 28 | * @var \Magento\Backend\Model\View\Result\ForwardFactory 29 | */ 30 | protected $_resultForwardFactory; 31 | 32 | /** 33 | * @var \Magento\Framework\View\Result\LayoutFactory 34 | */ 35 | protected $_resultLayoutFactory; 36 | 37 | /** 38 | * A factory that knows how to create a "page" result 39 | * Requires an instance of controller action in order to impose page type, 40 | * which is by convention is determined from the controller action class. 41 | * 42 | * @var \Magento\Framework\View\Result\PageFactory 43 | */ 44 | protected $_resultPageFactory; 45 | 46 | 47 | protected $_productFactory; 48 | 49 | protected $_productCollectionFactory; 50 | /** 51 | * Registry object. 52 | * 53 | * @var \Magento\Framework\Registry 54 | */ 55 | protected $_coreRegistry; 56 | 57 | /** 58 | * File Factory. 59 | * 60 | * @var \Magento\Framework\App\Response\Http\FileFactory 61 | */ 62 | protected $_fileFactory; 63 | 64 | public function __construct( 65 | \Magento\Backend\App\Action\Context $context, 66 | \Magento\Catalog\Model\ProductFactory $productFactory, 67 | \Magento\Catalog\Model\CategoryFactory $categoryFactory, 68 | \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory, 69 | \Magento\Framework\Registry $coreRegistry, 70 | \Magento\Framework\App\Response\Http\FileFactory $fileFactory, 71 | \Magento\Framework\View\Result\PageFactory $resultPageFactory, 72 | \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, 73 | \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, 74 | \Magento\Backend\Helper\Js $jsHelper, 75 | \Magento\Store\Model\StoreManagerInterface $storeManager 76 | ) { 77 | parent::__construct($context); 78 | $this->_coreRegistry = $coreRegistry; 79 | $this->_fileFactory = $fileFactory; 80 | $this->_jsHelper = $jsHelper; 81 | $this->_storeManager = $storeManager; 82 | 83 | $this->_resultPageFactory = $resultPageFactory; 84 | $this->_resultLayoutFactory = $resultLayoutFactory; 85 | $this->_resultForwardFactory = $resultForwardFactory; 86 | $this->_resultRedirectFactory = $context->getResultRedirectFactory(); 87 | 88 | $this->_productFactory = $productFactory; 89 | $this->_categoryFactory = $categoryFactory; 90 | $this->_productCollectionFactory = $productCollectionFactory; 91 | } 92 | 93 | protected function _isAllowed() 94 | { 95 | $namespace = (new \ReflectionObject($this))->getNamespaceName(); 96 | $string = strtolower(str_replace(__NAMESPACE__ . '\\','', $namespace)); 97 | $action = explode('\\', $string); 98 | $action = array_shift($action); 99 | return $this->_authorization->isAllowed("Magepow_MultiTranslate::multitranslate_$action"); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Catalog.php_speed: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 23:00:41 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml; 14 | 15 | abstract class Catalog extends \Magento\Backend\App\Action 16 | { 17 | /** 18 | * @var \Magento\Backend\Helper\Js 19 | */ 20 | protected $_jsHelper; 21 | 22 | /** 23 | * @var \Magento\Store\Model\StoreManagerInterface 24 | */ 25 | protected $_storeManager; 26 | 27 | /** 28 | * @var \Magento\Backend\Model\View\Result\ForwardFactory 29 | */ 30 | protected $_resultForwardFactory; 31 | 32 | /** 33 | * @var \Magento\Framework\View\Result\LayoutFactory 34 | */ 35 | protected $_resultLayoutFactory; 36 | 37 | /** 38 | * A factory that knows how to create a "page" result 39 | * Requires an instance of controller action in order to impose page type, 40 | * which is by convention is determined from the controller action class. 41 | * 42 | * @var \Magento\Framework\View\Result\PageFactory 43 | */ 44 | protected $_resultPageFactory; 45 | 46 | 47 | protected $_productFactory; 48 | protected $_productRepository; 49 | protected $_productResource; 50 | protected $_productCollectionFactory; 51 | /** 52 | * Registry object. 53 | * 54 | * @var \Magento\Framework\Registry 55 | */ 56 | protected $_coreRegistry; 57 | 58 | /** 59 | * File Factory. 60 | * 61 | * @var \Magento\Framework\App\Response\Http\FileFactory 62 | */ 63 | protected $_fileFactory; 64 | 65 | public function __construct( 66 | \Magento\Backend\App\Action\Context $context, 67 | \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, 68 | \Magento\Backend\Helper\Js $jsHelper, 69 | \Magento\Framework\Registry $coreRegistry, 70 | \Magento\Framework\App\Response\Http\FileFactory $fileFactory, 71 | \Magento\Framework\View\Result\PageFactory $resultPageFactory, 72 | \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, 73 | \Magento\Catalog\Model\CategoryFactory $categoryFactory, 74 | \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, 75 | \Magento\Catalog\Api\Data\ProductInterfaceFactory $productFactory, 76 | \Magento\Catalog\Model\ResourceModel\Product $productResource, 77 | \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory, 78 | \Magento\Store\Model\StoreManagerInterface $storeManager 79 | ) { 80 | parent::__construct($context); 81 | $this->_coreRegistry = $coreRegistry; 82 | $this->_fileFactory = $fileFactory; 83 | $this->_jsHelper = $jsHelper; 84 | $this->_storeManager = $storeManager; 85 | 86 | $this->_resultPageFactory = $resultPageFactory; 87 | $this->_resultLayoutFactory = $resultLayoutFactory; 88 | $this->_resultForwardFactory = $resultForwardFactory; 89 | $this->_resultRedirectFactory = $context->getResultRedirectFactory(); 90 | 91 | $this->_productFactory = $productFactory; 92 | $this->_productRepository = $productRepository; 93 | $this->_productResource = $productResource; 94 | $this->_categoryFactory = $categoryFactory; 95 | $this->_productCollectionFactory = $productCollectionFactory; 96 | } 97 | 98 | protected function _isAllowed() 99 | { 100 | $namespace = (new \ReflectionObject($this))->getNamespaceName(); 101 | $string = strtolower(str_replace(__NAMESPACE__ . '\\','', $namespace)); 102 | $action = explode('\\', $string); 103 | $action = array_shift($action); 104 | return $this->_authorization->isAllowed("Magepow_MultiTranslate::multitranslate_$action"); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Catalog/Edit.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 21:45:35 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Catalog; 14 | 15 | class Edit extends \Magepow\MultiTranslate\Controller\Adminhtml\Category 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | public function execute() 21 | { 22 | $id = $this->getRequest()->getParam('category_id'); 23 | $model = $this->_categoryFactory->create(); 24 | if ($id) { 25 | $model->setStoreId(0)->load($id); 26 | if (!$model->getId()) { 27 | $this->messageManager->addError(__('This Category no longer exists.')); 28 | $resultRedirect = $this->_resultRedirectFactory->create(); 29 | 30 | return $resultRedirect->setPath('*/*/'); 31 | } 32 | } 33 | 34 | $data = $this->_getSession()->getFormData(true); 35 | if (!empty($data)) { 36 | $model->setData($data); 37 | } 38 | 39 | $this->_coreRegistry->register('current_category', $model, 1); 40 | $this->_coreRegistry->register('category', $model, 1); 41 | $resultPage = $this->_resultPageFactory->create(); 42 | 43 | return $resultPage; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Catalog/Grid.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 21:45:00 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Catalog; 14 | 15 | class Grid extends \Magepow\MultiTranslate\Controller\Adminhtml\Action 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | public function execute() 21 | { 22 | $resultLayout = $this->_resultLayoutFactory->create(); 23 | 24 | return $resultLayout; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Catalog/Index.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 21:44:30 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Catalog; 14 | 15 | class Index extends \Magepow\MultiTranslate\Controller\Adminhtml\Action 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | public function execute() 21 | { 22 | if ($this->getRequest()->getQuery('ajax')) { 23 | $resultForward = $this->_resultForwardFactory->create(); 24 | $resultForward->forward('grid'); 25 | 26 | return $resultForward; 27 | } 28 | 29 | $resultPage = $this->_resultPageFactory->create(); 30 | 31 | return $resultPage; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Catalog/Save.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-27 11:40:46 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Catalog; 14 | 15 | use Magento\Framework\Controller\ResultFactory; 16 | 17 | class Save extends \Magepow\MultiTranslate\Controller\Adminhtml\Catalog 18 | { 19 | 20 | /** 21 | * @var \Magento\Framework\View\Result\PageFactory 22 | */ 23 | public function execute() 24 | { 25 | $resultRedirect = $this->_resultRedirectFactory->create(); 26 | 27 | if ($data = $this->getRequest()->getPostValue()) { 28 | $use_default = isset($data['use_default']) ? $data['use_default'] : array(); 29 | 30 | if ($id = $this->getRequest()->getParam('entity_id')) { 31 | $_data = $data; 32 | if(isset($_data['use_default'])) unset($_data['use_default']); 33 | if(isset($_data['form_key'])) unset($_data['form_key']); 34 | if(isset($_data['entity_id'])) unset($_data['entity_id']); 35 | foreach ( $_data as $key => $value) { 36 | $storeId = 0; 37 | 38 | /* 2 underline fix erro underline attribute short_description */ 39 | $tmp = explode('__', $key); 40 | if(!isset($tmp[1]) || !$tmp[1]) continue; 41 | $productId = (int) $tmp[1]; 42 | if(isset($tmp[2]) && $tmp[2]){ 43 | $storeId = (int) $tmp[2]; 44 | } 45 | $attributeCode = $tmp[0]; 46 | try { 47 | $productFactory = $this->_productFactory->create(); 48 | $product = $productFactory->setStoreId($storeId)->load($productId); 49 | $product->setStoreViewId($storeId); 50 | /** 51 | * Check "Use Default Value" checkboxes values 52 | */ 53 | if (isset($data['use_default'][$key])) { 54 | 55 | $product->setData($attributeCode, null); 56 | // if ($product->hasData("use_config_$attributeCode")) { 57 | $product->setData("use_config_$attributeCode", false); 58 | // } 59 | $product->save(); 60 | $this->messageManager->addSuccess(__("The %1 Product Id %2 has changed to Use Default Value.", $attributeCode, $productId)); 61 | } else { 62 | $product->setData($attributeCode, $value); 63 | $product->save(); 64 | $this->messageManager->addSuccess(__("The %1 Product Id %2 has been saved.", $attributeCode, $productId)); 65 | } 66 | 67 | 68 | } catch (\Exception $e) { 69 | $this->messageManager->addError($e->getMessage()); 70 | $this->messageManager->addException($e, __("Something went wrong while saving %1 the product Id %2", $attributeCode, $productId)); 71 | } 72 | } 73 | } 74 | // die('stop'); 75 | $this->_getSession()->setFormData($data); 76 | if ($this->getRequest()->getParam('back') === 'edit') { 77 | // return $resultRedirect->setPath( 78 | // '*/*/edit', 79 | // [ 80 | // 'category_id' => $this->getRequest()->getParam('entity_id'), 81 | // 'p' => $this->getRequest()->getParam('p') 82 | // ] 83 | // ); 84 | $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); 85 | 86 | $resultRedirect->setUrl($this->_redirect->getRefererUrl()); 87 | return $resultRedirect; 88 | } 89 | } 90 | 91 | return $resultRedirect->setPath('*/*/'); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Catalog/Save.php_speed: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-27 11:40:46 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Catalog; 14 | 15 | use Magento\Framework\Controller\ResultFactory; 16 | 17 | class Save extends \Magepow\MultiTranslate\Controller\Adminhtml\Catalog 18 | { 19 | 20 | /** 21 | * @var \Magento\Framework\View\Result\PageFactory 22 | */ 23 | public function execute() 24 | { 25 | $resultRedirect = $this->_resultRedirectFactory->create(); 26 | 27 | if ($data = $this->getRequest()->getPostValue()) { 28 | $use_default = isset($data['use_default']) ? $data['use_default'] : array(); 29 | 30 | if ($id = $this->getRequest()->getParam('entity_id')) { 31 | $_data = $data; 32 | if(isset($_data['use_default'])) unset($_data['use_default']); 33 | if(isset($_data['form_key'])) unset($_data['form_key']); 34 | if(isset($_data['entity_id'])) unset($_data['entity_id']); 35 | foreach ( $_data as $key => $value) { 36 | $storeId = 0; 37 | 38 | /* 2 underline fix erro underline attribute short_description */ 39 | $tmp = explode('__', $key); 40 | if(!isset($tmp[1]) || !$tmp[1]) continue; 41 | $productId = (int) $tmp[1]; 42 | if(isset($tmp[2]) && $tmp[2]){ 43 | $storeId = (int) $tmp[2]; 44 | } 45 | $attributeCode = $tmp[0]; 46 | try { 47 | 48 | $product = $this->_productRepository->getById($productId, false, $storeId); 49 | /** 50 | * Check "Use Default Value" checkboxes values 51 | */ 52 | if (isset($data['use_default']["$key"])) { 53 | $product->setData($attributeCode, null); 54 | // if ($product->hasData("use_config_$attributeCode")) { 55 | $product->setData("use_config_$attributeCode", false); 56 | // } 57 | $this->_productResource->save($product); 58 | $this->messageManager->addSuccess(__("The %1 Product Id %2 has changed to Use Default Value.", $attributeCode, $productId)); 59 | } else { 60 | $product->addAttributeUpdate($attributeCode, $value, $storeId); 61 | $this->messageManager->addSuccess(__("The %1 Product Id %2 has been saved.", $attributeCode, $productId)); 62 | } 63 | 64 | } catch (\Exception $e) { 65 | $this->messageManager->addError($e->getMessage()); 66 | $this->messageManager->addException($e, __("Something went wrong while saving the product Id %1", $productId)); 67 | } 68 | } 69 | } 70 | // die('stop'); 71 | $this->_getSession()->setFormData($data); 72 | if ($this->getRequest()->getParam('back') === 'edit') { 73 | // return $resultRedirect->setPath( 74 | // '*/*/edit', 75 | // [ 76 | // 'category_id' => $this->getRequest()->getParam('entity_id'), 77 | // 'p' => $this->getRequest()->getParam('p') 78 | // ] 79 | // ); 80 | $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); 81 | 82 | $resultRedirect->setUrl($this->_redirect->getRefererUrl()); 83 | return $resultRedirect; 84 | } 85 | } 86 | 87 | return $resultRedirect->setPath('*/*/'); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Category.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 11:07:36 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml; 14 | 15 | abstract class Category extends \Magento\Backend\App\Action 16 | { 17 | /** 18 | * @var \Magento\Backend\Helper\Js 19 | */ 20 | protected $_jsHelper; 21 | 22 | /** 23 | * @var \Magento\Store\Model\StoreManagerInterface 24 | */ 25 | protected $_storeManager; 26 | 27 | /** 28 | * @var \Magento\Backend\Model\View\Result\ForwardFactory 29 | */ 30 | protected $_resultForwardFactory; 31 | 32 | /** 33 | * @var \Magento\Framework\View\Result\LayoutFactory 34 | */ 35 | protected $_resultLayoutFactory; 36 | 37 | /** 38 | * A factory that knows how to create a "page" result 39 | * Requires an instance of controller action in order to impose page type, 40 | * which is by convention is determined from the controller action class. 41 | * 42 | * @var \Magento\Framework\View\Result\PageFactory 43 | */ 44 | protected $_resultPageFactory; 45 | 46 | 47 | protected $_categoryFactory; 48 | 49 | protected $_categoryCollectionFactory; 50 | /** 51 | * Registry object. 52 | * 53 | * @var \Magento\Framework\Registry 54 | */ 55 | protected $_coreRegistry; 56 | 57 | /** 58 | * File Factory. 59 | * 60 | * @var \Magento\Framework\App\Response\Http\FileFactory 61 | */ 62 | protected $_fileFactory; 63 | 64 | public function __construct( 65 | \Magento\Backend\App\Action\Context $context, 66 | \Magento\Catalog\Model\CategoryFactory $categoryFactory, 67 | \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollectionFactory, 68 | \Magento\Framework\Registry $coreRegistry, 69 | \Magento\Framework\App\Response\Http\FileFactory $fileFactory, 70 | \Magento\Framework\View\Result\PageFactory $resultPageFactory, 71 | \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, 72 | \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, 73 | \Magento\Backend\Helper\Js $jsHelper, 74 | \Magento\Store\Model\StoreManagerInterface $storeManager 75 | ) { 76 | parent::__construct($context); 77 | $this->_coreRegistry = $coreRegistry; 78 | $this->_fileFactory = $fileFactory; 79 | $this->_jsHelper = $jsHelper; 80 | $this->_storeManager = $storeManager; 81 | 82 | $this->_resultPageFactory = $resultPageFactory; 83 | $this->_resultLayoutFactory = $resultLayoutFactory; 84 | $this->_resultForwardFactory = $resultForwardFactory; 85 | $this->_resultRedirectFactory = $context->getResultRedirectFactory(); 86 | 87 | $this->_categoryFactory = $categoryFactory; 88 | $this->_categoryCollectionFactory = $categoryCollectionFactory; 89 | } 90 | 91 | protected function _isAllowed() 92 | { 93 | $namespace = (new \ReflectionObject($this))->getNamespaceName(); 94 | $string = strtolower(str_replace(__NAMESPACE__ . '\\','', $namespace)); 95 | $action = explode('\\', $string); 96 | $action = array_shift($action); 97 | return $this->_authorization->isAllowed("Magepow_MultiTranslate::multitranslate_$action"); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Category/Edit.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 21:27:50 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Category; 14 | 15 | class Edit extends \Magepow\MultiTranslate\Controller\Adminhtml\Category 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | public function execute() 21 | { 22 | $id = $this->getRequest()->getParam('category_id'); 23 | $model = $this->_categoryFactory->create(); 24 | if ($id) { 25 | $model->setStoreId(0)->load($id); 26 | if (!$model->getId()) { 27 | $this->messageManager->addError(__('This Category no longer exists.')); 28 | $resultRedirect = $this->_resultRedirectFactory->create(); 29 | 30 | return $resultRedirect->setPath('*/*/'); 31 | } 32 | } 33 | 34 | $data = $this->_getSession()->getFormData(true); 35 | if (!empty($data)) { 36 | $model->setData($data); 37 | } 38 | 39 | $this->_coreRegistry->register('current_category', $model, 1); 40 | $this->_coreRegistry->register('category', $model, 1); 41 | $resultPage = $this->_resultPageFactory->create(); 42 | 43 | return $resultPage; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Category/Grid.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 10:16:18 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Category; 14 | 15 | class Grid extends \Magepow\MultiTranslate\Controller\Adminhtml\Action 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | public function execute() 21 | { 22 | $resultLayout = $this->_resultLayoutFactory->create(); 23 | 24 | return $resultLayout; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Category/Index.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 10:16:04 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Category; 14 | 15 | class Index extends \Magepow\MultiTranslate\Controller\Adminhtml\Action 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | public function execute() 21 | { 22 | if ($this->getRequest()->getQuery('ajax')) { 23 | $resultForward = $this->_resultForwardFactory->create(); 24 | $resultForward->forward('grid'); 25 | 26 | return $resultForward; 27 | } 28 | 29 | $resultPage = $this->_resultPageFactory->create(); 30 | 31 | return $resultPage; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Category/Save.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 10:15:48 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Category; 14 | 15 | class Save extends \Magepow\MultiTranslate\Controller\Adminhtml\Category 16 | { 17 | 18 | /** 19 | * @var \Magento\Framework\View\Result\PageFactory 20 | */ 21 | public function execute() 22 | { 23 | $resultRedirect = $this->_resultRedirectFactory->create(); 24 | 25 | if ($data = $this->getRequest()->getPostValue()) { 26 | 27 | $model = $this->_categoryFactory->create(); 28 | 29 | if ($id = $this->getRequest()->getParam('entity_id')) { 30 | $model->setStoreId(0)->load($id); //default 31 | $model->addData($data); 32 | try { 33 | $model->save(); 34 | } catch (\Exception $e) { 35 | $this->messageManager->addError($e->getMessage()); 36 | $this->messageManager->addException($e, __('Something went wrong while saving the category.')); 37 | } 38 | $stores = $this->_storeManager->getStores(); 39 | foreach ($stores as $store) { 40 | $_storeId = $store->getId(); 41 | $model->setStoreId($_storeId)->load($id); 42 | $_data = array(); 43 | // $_data['entity_id'] = $data['entity_id']; 44 | 45 | /** 46 | * Check "Use Default Value" checkboxes values 47 | */ 48 | if (isset($data['use_default']["name_$_storeId"])) { 49 | $model->setData('name', null); 50 | // if ($model->hasData('use_config_name')) { 51 | $model->setData('use_config_name', false); 52 | // } 53 | } else { 54 | $_data['name'] = $data["name_$_storeId"]; 55 | } 56 | 57 | if (isset($data['use_default']["description_$_storeId"])) { 58 | $model->setData('description', null); 59 | // if ($model->hasData('use_config_description')) { 60 | $model->setData('use_config_description', false); 61 | // } 62 | } else { 63 | $_data['description'] = $data["description_$_storeId"]; 64 | } 65 | 66 | // foreach ($useDefaults as $attributeCode => $useDefaultState) { 67 | // if ($useDefaultState) { 68 | // $category->setData($attributeCode, null); 69 | // // UI component sends value even if field is disabled, so 'Use Config Settings' must be reset to false 70 | // if ($category->hasData('use_config_' . $attributeCode)) { 71 | // $category->setData('use_config_' . $attributeCode, false); 72 | // } 73 | // } 74 | // } 75 | 76 | $model->addData($_data)->setStoreViewId($_storeId); 77 | try { 78 | $model->save(); 79 | } catch (\Exception $e) { 80 | $this->messageManager->addError($e->getMessage()); 81 | $this->messageManager->addException($e, __('Something went wrong while saving the category.')); 82 | } 83 | } 84 | } 85 | 86 | try { 87 | $model->save(); 88 | 89 | $this->messageManager->addSuccess(__('The Category has been saved.')); 90 | $this->_getSession()->setFormData(false); 91 | $storeViewId = $this->_storeManager->getStore()->getId(); 92 | if ($this->getRequest()->getParam('back') === 'edit') { 93 | return $resultRedirect->setPath( 94 | '*/*/edit', 95 | [ 96 | 'category_id' => $model->getId(), 97 | '_current' => true, 98 | 'store' => $storeViewId, 99 | 'current_category_id' => $this->getRequest()->getParam('current_category_id'), 100 | 'saveandclose' => $this->getRequest()->getParam('saveandclose'), 101 | ] 102 | ); 103 | } elseif ($this->getRequest()->getParam('back') === 'new') { 104 | return $resultRedirect->setPath( 105 | '*/*/new', 106 | ['_current' => TRUE] 107 | ); 108 | } 109 | 110 | return $resultRedirect->setPath('*/*/'); 111 | } catch (\Exception $e) { 112 | $this->messageManager->addError($e->getMessage()); 113 | $this->messageManager->addException($e, __('Something went wrong while saving the category.')); 114 | } 115 | 116 | $this->_getSession()->setFormData($data); 117 | 118 | return $resultRedirect->setPath( 119 | '*/*/edit', 120 | ['category_id' => $this->getRequest()->getParam('category_id')] 121 | ); 122 | } 123 | 124 | return $resultRedirect->setPath('*/*/'); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Product.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-02-23 18:59:34 9 | * @@Modify Date: 2020-03-16 10:26:07 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml; 14 | 15 | abstract class Product extends \Magento\Backend\App\Action 16 | { 17 | /** 18 | * @var \Magento\Backend\Helper\Js 19 | */ 20 | protected $_jsHelper; 21 | 22 | /** 23 | * @var \Magento\Store\Model\StoreManagerInterface 24 | */ 25 | protected $_storeManager; 26 | 27 | /** 28 | * @var \Magento\Backend\Model\View\Result\ForwardFactory 29 | */ 30 | protected $_resultForwardFactory; 31 | 32 | /** 33 | * @var \Magento\Framework\View\Result\LayoutFactory 34 | */ 35 | protected $_resultLayoutFactory; 36 | 37 | /** 38 | * A factory that knows how to create a "page" result 39 | * Requires an instance of controller action in order to impose page type, 40 | * which is by convention is determined from the controller action class. 41 | * 42 | * @var \Magento\Framework\View\Result\PageFactory 43 | */ 44 | protected $_resultPageFactory; 45 | 46 | 47 | protected $_productFactory; 48 | 49 | protected $_productCollectionFactory; 50 | /** 51 | * Registry object. 52 | * 53 | * @var \Magento\Framework\Registry 54 | */ 55 | protected $_coreRegistry; 56 | 57 | /** 58 | * File Factory. 59 | * 60 | * @var \Magento\Framework\App\Response\Http\FileFactory 61 | */ 62 | protected $_fileFactory; 63 | 64 | public function __construct( 65 | \Magento\Backend\App\Action\Context $context, 66 | \Magento\Catalog\Model\ProductFactory $productFactory, 67 | \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory, 68 | \Magento\Framework\Registry $coreRegistry, 69 | \Magento\Framework\App\Response\Http\FileFactory $fileFactory, 70 | \Magento\Framework\View\Result\PageFactory $resultPageFactory, 71 | \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, 72 | \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, 73 | \Magento\Backend\Helper\Js $jsHelper, 74 | \Magento\Store\Model\StoreManagerInterface $storeManager 75 | ) { 76 | parent::__construct($context); 77 | $this->_coreRegistry = $coreRegistry; 78 | $this->_fileFactory = $fileFactory; 79 | $this->_jsHelper = $jsHelper; 80 | $this->_storeManager = $storeManager; 81 | 82 | $this->_resultPageFactory = $resultPageFactory; 83 | $this->_resultLayoutFactory = $resultLayoutFactory; 84 | $this->_resultForwardFactory = $resultForwardFactory; 85 | $this->_resultRedirectFactory = $context->getResultRedirectFactory(); 86 | 87 | $this->_productFactory = $productFactory; 88 | $this->_productCollectionFactory = $productCollectionFactory; 89 | } 90 | 91 | protected function _isAllowed() 92 | { 93 | $namespace = (new \ReflectionObject($this))->getNamespaceName(); 94 | $string = strtolower(str_replace(__NAMESPACE__ . '\\','', $namespace)); 95 | $action = explode('\\', $string); 96 | $action = array_shift($action); 97 | return $this->_authorization->isAllowed("Magepow_MultiTranslate::multitranslate_$action"); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Product/Edit.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-21 18:56:36 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Product; 14 | 15 | class Edit extends \Magepow\MultiTranslate\Controller\Adminhtml\Product 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | public function execute() 21 | { 22 | $id = $this->getRequest()->getParam('product_id'); 23 | $model = $this->_productFactory->create(); 24 | 25 | if ($id) { 26 | $model->setStoreId(0)->load($id); 27 | if (!$model->getId()) { 28 | $this->messageManager->addError(__('This Product no longer exists.')); 29 | $resultRedirect = $this->_resultRedirectFactory->create(); 30 | 31 | return $resultRedirect->setPath('*/*/'); 32 | } 33 | } 34 | 35 | $data = $this->_getSession()->getFormData(true); 36 | if (!empty($data)) { 37 | $model->setData($data); 38 | } 39 | 40 | $this->_coreRegistry->register('current_product', $model, 1); 41 | $this->_coreRegistry->register('product', $model, 1); 42 | $resultPage = $this->_resultPageFactory->create(); 43 | 44 | return $resultPage; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Product/Grid.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-21 14:25:33 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Product; 14 | 15 | class Grid extends \Magepow\MultiTranslate\Controller\Adminhtml\Action 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | public function execute() 21 | { 22 | $resultLayout = $this->_resultLayoutFactory->create(); 23 | 24 | return $resultLayout; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Product/Index.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-21 14:26:05 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Product; 14 | 15 | class Index extends \Magepow\MultiTranslate\Controller\Adminhtml\Action 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | public function execute() 21 | { 22 | if ($this->getRequest()->getQuery('ajax')) { 23 | $resultForward = $this->_resultForwardFactory->create(); 24 | $resultForward->forward('grid'); 25 | 26 | return $resultForward; 27 | } 28 | 29 | $resultPage = $this->_resultPageFactory->create(); 30 | 31 | return $resultPage; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Product/Save.php: -------------------------------------------------------------------------------- 1 | 8 | * @@Create Date: 2016-01-05 10:40:51 9 | * @@Modify Date: 2018-03-26 17:31:12 10 | * @@Function: 11 | */ 12 | 13 | namespace Magepow\MultiTranslate\Controller\Adminhtml\Product; 14 | 15 | class Save extends \Magepow\MultiTranslate\Controller\Adminhtml\Product 16 | { 17 | 18 | /** 19 | * @var \Magento\Framework\View\Result\PageFactory 20 | */ 21 | public function execute() 22 | { 23 | $resultRedirect = $this->_resultRedirectFactory->create(); 24 | 25 | if ($data = $this->getRequest()->getPostValue()) { 26 | 27 | $model = $this->_productFactory->create(); 28 | 29 | if ($id = $this->getRequest()->getParam('entity_id')) { 30 | $model->setStoreId(0)->load($id); //default 31 | $model->addData($data); 32 | try { 33 | $model->save(); 34 | } catch (\Exception $e) { 35 | $this->messageManager->addError($e->getMessage()); 36 | $this->messageManager->addException($e, __('Something went wrong while saving the product.')); 37 | } 38 | $stores = $this->_storeManager->getStores(); 39 | foreach ($stores as $store) { 40 | $_storeId = $store->getId(); 41 | $model->setStoreId($_storeId)->load($id); 42 | $_data = array(); 43 | // $_data['entity_id'] = $data['entity_id']; 44 | 45 | /** 46 | * Check "Use Default Value" checkboxes values 47 | */ 48 | if (isset($data['use_default']["name_$_storeId"])) { 49 | $model->setData('name', null); 50 | // if ($model->hasData('use_config_name')) { 51 | $model->setData('use_config_name', false); 52 | // } 53 | } else { 54 | $model->setData('name', $data["name_$_storeId"]); 55 | } 56 | 57 | if (isset($data['use_default']["description_$_storeId"])) { 58 | $model->setData('description', null); 59 | // if ($model->hasData('use_config_description')) { 60 | $model->setData('use_config_description', false); 61 | // } 62 | } else { 63 | $model->setData('description', $data["description_$_storeId"]); 64 | } 65 | if (isset($data['use_default']["short_description_$_storeId"])) { 66 | $model->setData('short_description', null); 67 | // if ($model->hasData('use_config_short_description')) { 68 | $model->setData('use_config_short_description', false); 69 | // } 70 | } else { 71 | $model->setData('short_description', $data["short_description_$_storeId"]); 72 | } 73 | 74 | // foreach ($useDefaults as $attributeCode => $useDefaultState) { 75 | // if ($useDefaultState) { 76 | // $product->setData($attributeCode, null); 77 | // // UI component sends value even if field is disabled, so 'Use Config Settings' must be reset to false 78 | // if ($product->hasData('use_config_' . $attributeCode)) { 79 | // $product->setData('use_config_' . $attributeCode, false); 80 | // } 81 | // } 82 | // } 83 | // if (isset($data['use_default']["name_$_storeId"])){ 84 | // $model->setData('name', null); 85 | // $model->setData('use_config_name', false); 86 | // } 87 | 88 | $model->setStoreViewId($_storeId); 89 | try { 90 | $model->save(); 91 | } catch (\Exception $e) { 92 | $this->messageManager->addError($e->getMessage()); 93 | $this->messageManager->addException($e, __('Something went wrong while saving the product.')); 94 | } 95 | } 96 | } 97 | 98 | try { 99 | $model->save(); 100 | 101 | $this->messageManager->addSuccess(__('The Product has been saved.')); 102 | $this->_getSession()->setFormData(false); 103 | $storeViewId = $this->_storeManager->getStore()->getId(); 104 | if ($this->getRequest()->getParam('back') === 'edit') { 105 | return $resultRedirect->setPath( 106 | '*/*/edit', 107 | [ 108 | 'product_id' => $model->getId(), 109 | '_current' => true, 110 | 'store' => $storeViewId, 111 | 'current_product_id' => $this->getRequest()->getParam('current_product_id'), 112 | 'saveandclose' => $this->getRequest()->getParam('saveandclose'), 113 | ] 114 | ); 115 | } elseif ($this->getRequest()->getParam('back') === 'new') { 116 | return $resultRedirect->setPath( 117 | '*/*/new', 118 | ['_current' => TRUE] 119 | ); 120 | } 121 | 122 | return $resultRedirect->setPath('*/*/'); 123 | } catch (\Exception $e) { 124 | $this->messageManager->addError($e->getMessage()); 125 | $this->messageManager->addException($e, __('Something went wrong while saving the product.')); 126 | } 127 | 128 | $this->_getSession()->setFormData($data); 129 | 130 | return $resultRedirect->setPath( 131 | '*/*/edit', 132 | ['product_id' => $this->getRequest()->getParam('product_id')] 133 | ); 134 | } 135 | 136 | return $resultRedirect->setPath('*/*/'); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [](https://shopify.pxf.io/VyL446) 2 | 3 | ## Magento 2 multi translate Extension 4 | 5 | When your Magento store has multiple views in different languages, the same products, categories, and catalogs are available in each store view. However, you will need to translate some information such as product name, product description, product details..., and the same with categories in each language. To do this, you will need to do the same manipulation, this thing leads to waste much of your time such as choose store views, after completing you will need to save information three times on one product if you have three languages,...or even much more if you have upper 10 languages. 6 | 7 | [**Multi Translate extension for Magento 2 by Magepow**](https://magepow.com/magento-2-multi-translate.html) allows you to collect all information in one time to fill in all information for all languages. After completing, you only need to save one time. With a product, you will able to translate its name, product description (short and long) for all store views at one time. With a category, you will able to translate its name and description at one time. And, with a catalog, you will able to translate all categories' names in that catalog. 8 | 9 | [![result-recent-order-notification-for-magento-img](https://github.com/magepow/magento-2-multiple-translate/blob/master/media/magento-2-multitranslate.png)](https://magepow.com/magento-2-multi-translate.html) 10 | 11 | ### Outstanding Features 12 | 13 | - For each product/category/catalog translating: Complete in one saving time, no need to choose store view. No worry about the number of languages 14 | 15 | - All store view language in just one window 16 | 17 | - Allow translating product information quickly such as product name, product description, product detail 18 | 19 | - Allow translating category information quickly such as Category name, description 20 | 21 | - Allow translating catalog information quickly such as the name in each language 22 | 23 | - Easy to install and manage in admin Panel, no coding needed 24 | 25 | [![Latest Stable Version](https://poser.pugx.org/magepow/multitranslate/v/stable)](https://packagist.org/packages/magepow/multitranslate) 26 | [![Total Downloads](https://poser.pugx.org/magepow/multitranslate/downloads)](https://packagist.org/packages/magepow/multitranslate) 27 | [![Daily Downloads](https://poser.pugx.org/magepow/multitranslate/d/daily)](https://packagist.org/packages/magepow/multitranslate) 28 | 29 | ### See more 30 | 31 | - Detailed description, Demo frontend, Demo backend: [Multi Translate extension ](https://magepow.com/magento-2-multi-translate.html) 32 | 33 | ## How to use Magento 2 Multitranslate 34 | ### 1. How to install Multi Translate extension 35 | #### ✓ Install Magepow Multitranslate via composer (recommend) 36 | Run the following command in Magento 2 root folder: 37 | 38 | ``` 39 | composer require magepow/multitranslate 40 | php bin/magento setup:upgrade 41 | php bin/magento setup:static-content:deploy -f 42 | ``` 43 | 44 | ### 3. User Guide 45 | 46 | Adding this attribute to magento is really important, especially for websites that serve customers in many different countries. 47 | 48 | After installing the extension, you just need to log in to the admin panel and start managing translations of all languages ​​in the store. Perform translation and completion operations in just one page and one time. It's great, isn't it? 49 | 50 | [Online Document](https://docs.alothemes.com/m2/extension/multitranslate/) 51 | 52 | ## Donation 53 | 54 | If this project help you reduce time to develop, you can give me a cup of coffee :) 55 | 56 | [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/paypalme/alopay) 57 | 58 | 59 | **[Our Magento 2 Extensions](https://magepow.com/magento-2-extensions.html)** 60 | 61 | * [Magento 2 Recent Sales Notification](https://magepow.com/magento-2-recent-order-notification.html) 62 | 63 | * [Magento 2 Categories Extension](https://magepow.com/magento-categories-extension.html) 64 | 65 | * [Magento 2 Sticky Cart](https://magepow.com/magento-sticky-cart.html) 66 | 67 | * [Magento 2 Ajax Contact](https://magepow.com/magento-ajax-contact-form.html) 68 | 69 | * [Magento 2 Lazy Load](https://magepow.com/magento-lazy-load.html) 70 | 71 | * [Magento 2 Mutil Translate](https://magepow.com/magento-multi-translate.html) 72 | 73 | * [Magento 2 Instagram Integration](https://magepow.com/magento-2-instagram.html) 74 | 75 | * [Magento 2 Lookbook Pin Products](https://magepow.com/lookbook-pin-products.html) 76 | 77 | * [Magento 2 Product Slider](https://magepow.com/magento-product-slider.html) 78 | 79 | * [Magento 2 Product Banner](https://magepow.com/magento-2-banner-slider.html) 80 | 81 | **[Our Magento 2 services](https://magepow.com/magento-services.html)** 82 | 83 | * [PSD to Magento 2 Theme Conversion](https://alothemes.com/psd-to-magento-theme-conversion.html) 84 | 85 | * [Magento 2 Speed Optimization Service](https://magepow.com/magento-speed-optimization-service.html) 86 | 87 | * [Magento 2 Security Patch Installation](https://magepow.com/magento-security-patch-installation.html) 88 | 89 | * [Magento 2 Website Maintenance Service](https://magepow.com/website-maintenance-service.html) 90 | 91 | * [Magento 2 Professional Installation Service](https://magepow.com/professional-installation-service.html) 92 | 93 | * [Magento 2 Upgrade Service](https://magepow.com/magento-upgrade-service.html) 94 | 95 | * [Magento 2 Customization Service](https://magepow.com/customization-service.html) 96 | 97 | * [Hire Magento 2 Developer](https://magepow.com/hire-magento-developer.html) 98 | 99 | **[Our Magento 2 Themes](https://alothemes.com/)** 100 | 101 | * [Expert Multipurpose Responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/expert-premium-responsive-magento-2-and-1-support-rtl-magento-2-/21667789) 102 | 103 | * [Gecko Premium Responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/gecko-responsive-magento-2-theme-rtl-supported/24677410) 104 | 105 | * [Milano Fashion Responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/milano-fashion-responsive-magento-1-2-theme/12141971) 106 | 107 | * [Electro 2 Responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/electro2-premium-responsive-magento-2-rtl-supported/26875864) 108 | 109 | * [Electro Responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/electro-responsive-magento-1-2-theme/17042067) 110 | 111 | * [Pizzaro Food responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/pizzaro-food-responsive-magento-1-2-theme/19438157) 112 | 113 | * [Biolife organic responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/biolife-organic-food-magento-2-theme-rtl-supported/25712510) 114 | 115 | * [Market responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/market-responsive-magento-2-theme/22997928) 116 | 117 | * [Kuteshop responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/kuteshop-multipurpose-responsive-magento-1-2-theme/12985435) 118 | 119 | * [Bencher - Responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/bencher-responsive-magento-1-2-theme/15787772) 120 | 121 | * [Supermarket Responsive Magento 2 Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/supermarket-responsive-magento-1-2-theme/18447995) 122 | 123 | **[Our Shopify Themes](https://themeforest.net/user/alotheme)** 124 | 125 | * [Dukamarket - Multipurpose Shopify Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/dukamarket-multipurpose-shopify-theme/36158349) 126 | 127 | * [Ohey - Multipurpose Shopify Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/ohey-multipurpose-shopify-theme/34624195) 128 | 129 | * [Flexon - Multipurpose Shopify Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/flexon-multipurpose-shopify-theme/33461048) 130 | 131 | **[Our Shopify App](https://apps.shopify.com/partners/maggicart)** 132 | 133 | * [Magepow Infinite Scroll](https://apps.shopify.com/magepow-infinite-scroll) 134 | 135 | * [Magepow Promotionbar](https://apps.shopify.com/magepow-promotionbar) 136 | 137 | * [Magepow Size Chart](https://apps.shopify.com/magepow-size-chart) 138 | 139 | **[Our WordPress Theme](https://themeforest.net/user/alotheme/portfolio)** 140 | 141 | * [SadesMarket - Multipurpose WordPress Theme](https://1.envato.market/c/1314680/275988/4415?u=https://themeforest.net/item/sadesmarket-multipurpose-wordpress-theme/35369933) 142 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magepow/multitranslate", 3 | "description": "Multi Translate extension for Magento 2 allows you to collect all information in one time to fill in all information for all languages", 4 | "require": { 5 | "magepow/core": "^1.0.0" 6 | }, 7 | "type": "magento2-module", 8 | "license": [ 9 | "OSL-3.0", 10 | "AFL-3.0" 11 | ], 12 | "authors": [ 13 | { 14 | "name": "Magepow", 15 | "email": "support@magepow.com", 16 | "homepage": "https://magepow.com", 17 | "role": "Technical Support" 18 | } 19 | ], 20 | "autoload": { 21 | "psr-4": { 22 | "Magepow\\MultiTranslate\\": "" 23 | }, 24 | "files": [ 25 | "registration.php" 26 | ] 27 | } 28 | } -------------------------------------------------------------------------------- /etc/acl.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /etc/adminhtml/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /etc/adminhtml/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /media/magento-2-multitranslate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magepow/magento-2-multiple-translate/fcd8d2492c84a6db6c297a3e98df13ddd6e4c273/media/magento-2-multitranslate.png -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Magepow_MultiTranslate::multitranslate 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /view/adminhtml/layout/multitranslate_catalog_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /view/adminhtml/layout/multitranslate_catalog_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | Catalog 17 | 18 | 19 | 20 | 21 | Magepow_MultiTranslate::multitranslate 22 | 23 | 24 | 25 | 26 | Catalog 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /view/adminhtml/layout/multitranslate_category_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Magepow_MultiTranslate::multitranslate 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /view/adminhtml/layout/multitranslate_category_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /view/adminhtml/layout/multitranslate_category_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | Category 17 | 18 | 19 | 20 | 21 | Magepow_MultiTranslate::multitranslate 22 | 23 | 24 | 25 | 26 | Category 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /view/adminhtml/layout/multitranslate_product_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Magepow_MultiTranslate::multitranslate 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /view/adminhtml/layout/multitranslate_product_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /view/adminhtml/layout/multitranslate_product_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | Product 17 | 18 | 19 | 20 | 21 | Magepow_MultiTranslate::multitranslate 22 | 23 | 24 | 25 | 26 | Product 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /view/adminhtml/layout/multitranslate_product_new.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /view/adminhtml/templates/html/pager.phtml: -------------------------------------------------------------------------------- 1 | 13 | getCollection()->getSize()) : ?> 14 | 15 | getUseContainer()) : ?> 16 |
17 | 18 | 19 | getShowAmounts()) : ?> 20 |

21 | 22 | getLastPageNum()>1) : ?> 23 | escapeHtml(__('Items %1 to %2 of %3 total', $block->getFirstNum(), $block->getLastNum(), $block->getTotalNum())) ?> 24 | getTotalNum() == 1) : ?> 25 | escapeHtml(__('%1 Item', $block->getTotalNum())) ?> 26 | 27 | escapeHtml(__('%1 Item(s)', $block->getTotalNum())) ?> 28 | 29 | 30 |

31 | 32 | 33 | getLastPageNum()>1) : ?> 34 |
35 | escapeHtml(__('Page')) ?> 36 | 115 |
116 | 117 | 118 | 133 | 134 | getUseContainer()) : ?> 135 |
136 | 137 | 138 | 139 | 252 | --------------------------------------------------------------------------------