Version Notes
notes
Download this release
Release Info
Developer | Marcin Klauza |
Extension | 2f0ed0fddbc299a929e59604a51b5159 |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/Form/Abstract.php +26 -62
- app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/{MassActionForm.php → Form/Massaction.php} +1 -1
- app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/{SettingsForm.php → Form/Settings.php} +1 -1
- app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/{Form → System/Config/Form}/Pattern.php +2 -3
- app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/Urlrewrite/Grid.php +0 -138
- app/code/community/Mklauza/CustomProductUrls/Helper/Data.php +128 -122
- app/code/community/Mklauza/CustomProductUrls/Model/Adminhtml/Observer.php +1 -36
- app/code/community/Mklauza/CustomProductUrls/Model/Catalog/Product/Url.php +1 -1
- app/code/community/Mklauza/CustomProductUrls/Model/Catalog/Resource/Product/Action.php +5 -2
- app/code/community/Mklauza/CustomProductUrls/Model/Catalog/Resource/Product/Attribute/Backend/_Urlkey.php +0 -46
- app/code/community/Mklauza/CustomProductUrls/Model/Pattern.php +203 -0
- app/code/community/Mklauza/CustomProductUrls/controllers/Adminhtml/Catalog/Product/Action/ProductUrlsMassActionController.php +28 -23
- app/code/community/Mklauza/CustomProductUrls/controllers/Adminhtml/ProductUrlsController.php +8 -25
- app/code/community/Mklauza/CustomProductUrls/etc/adminhtml.xml +20 -39
- app/code/community/Mklauza/CustomProductUrls/etc/config.xml +18 -4
- app/code/community/Mklauza/CustomProductUrls/etc/system.xml +1 -1
- app/design/adminhtml/default/default/layout/mklauza/product_urls.xml +29 -16
- app/design/adminhtml/default/default/template/mklauza/customproducturls/massaction.phtml +26 -295
- app/design/adminhtml/default/default/template/mklauza/customproducturls/system/settings.phtml +44 -305
- package.xml +5 -5
app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/Form/Abstract.php
CHANGED
@@ -21,44 +21,43 @@
|
|
21 |
*/
|
22 |
|
23 |
abstract class Mklauza_CustomProductUrls_Block_Adminhtml_Form_Abstract extends Mage_Adminhtml_Block_Template {
|
24 |
-
|
25 |
-
// private $_attributesCollection;
|
26 |
-
// private $_productAttributes;
|
27 |
-
private $_patternChunks;
|
28 |
-
private $_attributesChunks;
|
29 |
-
private $_patternStr;
|
30 |
private $_allowedFormats = array('price');//, 'date', 'price', 'wee');
|
31 |
|
32 |
-
public function
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
|
|
|
|
|
36 |
public function getExampleUrl() {
|
37 |
return Mage::helper('adminhtml')->getUrl('adminhtml/ProductUrls/example');
|
38 |
}
|
39 |
|
40 |
-
|
41 |
-
|
42 |
}
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
}
|
51 |
-
}
|
52 |
-
return $this->_patternStr;
|
53 |
-
}
|
54 |
|
55 |
-
private function
|
56 |
if(!$chunk || !isset($chunk['value']) || !isset($chunk['type'])) {
|
57 |
return '';
|
58 |
}
|
59 |
|
60 |
if($chunk['type'] === 'attribute') {
|
61 |
-
$attributes = $this->
|
62 |
$attrId = $chunk['value'];
|
63 |
return '<span class="inputTags-item blocked" data-value="' . $attrId . '">'
|
64 |
. '<span class="value">' . $attributes[$attrId] . '</span>'
|
@@ -68,61 +67,26 @@ abstract class Mklauza_CustomProductUrls_Block_Adminhtml_Form_Abstract extends M
|
|
68 |
}
|
69 |
}
|
70 |
|
71 |
-
public function getAttributesCollection() {
|
72 |
-
return $this->_getHelper()->getAttributesCollection();
|
73 |
-
}
|
74 |
-
|
75 |
-
public function getProductAttributes() {
|
76 |
-
return $this->_getHelper()->getProductAttributes();
|
77 |
-
}
|
78 |
-
|
79 |
-
public function getPatternChunks() {
|
80 |
-
if($this->_patternChunks === null) {
|
81 |
-
$urlPattern = $this->getPatternStr();
|
82 |
-
$this->_patternChunks = $this->_getHelper()->extractChunks($urlPattern);
|
83 |
-
}
|
84 |
-
return $this->_patternChunks;
|
85 |
-
}
|
86 |
-
|
87 |
public function getPatternHtml() {
|
88 |
-
|
89 |
-
$chunks = $this->getPatternChunks();
|
90 |
$html = '';
|
91 |
foreach ($chunks as $_chunk) {
|
92 |
-
$html .= $this->
|
93 |
}
|
94 |
|
95 |
return $html;
|
96 |
}
|
97 |
|
98 |
-
public function getAttributesChunks() {
|
99 |
-
if($this->_attributesChunks === null) {
|
100 |
-
$attributes = $this->getProductAttributes();
|
101 |
-
$patternChunks = $this->getPatternChunks();
|
102 |
-
foreach($patternChunks as $chunk) {
|
103 |
-
if($chunk['type'] === 'attribute') {
|
104 |
-
$attrId = $chunk['value'];
|
105 |
-
unset($attributes[$attrId]);
|
106 |
-
}
|
107 |
-
}
|
108 |
-
$this->_attributesChunks = array();
|
109 |
-
foreach($attributes as $id => $name) {
|
110 |
-
$this->_attributesChunks[] = array('value' => $id, 'type' => 'attribute');
|
111 |
-
}
|
112 |
-
}
|
113 |
-
return $this->_attributesChunks;
|
114 |
-
}
|
115 |
-
|
116 |
public function getAttributesCloudHtml() {
|
117 |
-
$chunks = $this->
|
118 |
$html = '';
|
119 |
foreach ($chunks as $_chunk) {
|
120 |
-
$html .= $this->
|
121 |
}
|
122 |
return $html;
|
123 |
}
|
124 |
|
125 |
-
protected function
|
126 |
return Mage::helper('mklauza_customproducturls');
|
127 |
}
|
128 |
|
21 |
*/
|
22 |
|
23 |
abstract class Mklauza_CustomProductUrls_Block_Adminhtml_Form_Abstract extends Mage_Adminhtml_Block_Template {
|
24 |
+
|
|
|
|
|
|
|
|
|
|
|
25 |
private $_allowedFormats = array('price');//, 'date', 'price', 'wee');
|
26 |
|
27 |
+
public function _construct() {
|
28 |
+
if( $this->getPatternObject()->getPattern() === null) {
|
29 |
+
if(Mage::app()->getRequest()->getParam('pattern', null)) {
|
30 |
+
$this->getPatternObject()->setPattern(Mage::app()->getRequest()->getParam('pattern'));
|
31 |
+
} else {
|
32 |
+
$this->getPatternObject()->setPattern($this->_helper()->getConfigPattern());
|
33 |
+
}
|
34 |
+
}
|
35 |
}
|
36 |
|
37 |
+
public abstract function getSubmitUrl();
|
38 |
+
|
39 |
public function getExampleUrl() {
|
40 |
return Mage::helper('adminhtml')->getUrl('adminhtml/ProductUrls/example');
|
41 |
}
|
42 |
|
43 |
+
protected function getPatternObject() {
|
44 |
+
return Mage::getSingleton('mklauza_customproducturls/pattern');
|
45 |
}
|
46 |
|
47 |
+
/*
|
48 |
+
*
|
49 |
+
*/
|
50 |
+
// public function getPatternStr() {
|
51 |
+
// return $this->getPatternObject()->getPattern();
|
52 |
+
// }
|
|
|
|
|
|
|
|
|
53 |
|
54 |
+
private function render(array $chunk = null) {
|
55 |
if(!$chunk || !isset($chunk['value']) || !isset($chunk['type'])) {
|
56 |
return '';
|
57 |
}
|
58 |
|
59 |
if($chunk['type'] === 'attribute') {
|
60 |
+
$attributes = $this->getPatternObject()->getAllProductAttributes();
|
61 |
$attrId = $chunk['value'];
|
62 |
return '<span class="inputTags-item blocked" data-value="' . $attrId . '">'
|
63 |
. '<span class="value">' . $attributes[$attrId] . '</span>'
|
67 |
}
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
public function getPatternHtml() {
|
71 |
+
$chunks = $this->getPatternObject()->getPatternChunks();
|
|
|
72 |
$html = '';
|
73 |
foreach ($chunks as $_chunk) {
|
74 |
+
$html .= $this->render($_chunk);
|
75 |
}
|
76 |
|
77 |
return $html;
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
public function getAttributesCloudHtml() {
|
81 |
+
$chunks = $this->getPatternObject()->getAllProductAttributesChunks();
|
82 |
$html = '';
|
83 |
foreach ($chunks as $_chunk) {
|
84 |
+
$html .= $this->render($_chunk);
|
85 |
}
|
86 |
return $html;
|
87 |
}
|
88 |
|
89 |
+
protected function _helper() {
|
90 |
return Mage::helper('mklauza_customproducturls');
|
91 |
}
|
92 |
|
app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/{MassActionForm.php → Form/Massaction.php}
RENAMED
@@ -20,7 +20,7 @@
|
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
|
23 |
-
class
|
24 |
|
25 |
public function _construct() {
|
26 |
parent::_construct();
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
|
23 |
+
class Mklauza_CustomProductUrls_Block_Adminhtml_Form_Massaction extends Mklauza_CustomProductUrls_Block_Adminhtml_Form_Abstract {
|
24 |
|
25 |
public function _construct() {
|
26 |
parent::_construct();
|
app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/{SettingsForm.php → Form/Settings.php}
RENAMED
@@ -20,7 +20,7 @@
|
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
|
23 |
-
class
|
24 |
|
25 |
public function _construct() {
|
26 |
parent::_construct();
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
|
23 |
+
class Mklauza_CustomProductUrls_Block_Adminhtml_Form_Settings extends Mklauza_CustomProductUrls_Block_Adminhtml_Form_Abstract {
|
24 |
|
25 |
public function _construct() {
|
26 |
parent::_construct();
|
app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/{Form → System/Config/Form}/Pattern.php
RENAMED
@@ -20,13 +20,12 @@
|
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
|
23 |
-
class
|
24 |
|
25 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
26 |
{
|
27 |
-
// $this->setElement($element);
|
28 |
$element->setType('hidden');
|
29 |
-
$html = $this->getLayout()->createBlock('mklauza_customproducturls/
|
30 |
->setElement($element)
|
31 |
->toHtml();
|
32 |
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
|
23 |
+
class Mklauza_CustomProductUrls_Block_Adminhtml_System_Config_Form_Pattern extends Mage_Adminhtml_Block_System_Config_Form_Field {
|
24 |
|
25 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
26 |
{
|
|
|
27 |
$element->setType('hidden');
|
28 |
+
$html = $this->getLayout()->createBlock('mklauza_customproducturls/adminhtml_form_settings')
|
29 |
->setElement($element)
|
30 |
->toHtml();
|
31 |
|
app/code/community/Mklauza/CustomProductUrls/Block/Adminhtml/Urlrewrite/Grid.php
DELETED
@@ -1,138 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magento.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magento.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_Adminhtml
|
23 |
-
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
-
*/
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Adminhtml urlrewrite grid block
|
29 |
-
*
|
30 |
-
* @category Mage
|
31 |
-
* @package Mage_Adminhtml
|
32 |
-
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
-
*/
|
34 |
-
class Mklauza_CustomProductUrls_Adminhtml_Block_Urlrewrite_Grid extends Mage_Adminhtml_Block_Urlrewrite_Grid
|
35 |
-
{
|
36 |
-
|
37 |
-
protected function _prepareColumns()
|
38 |
-
{
|
39 |
-
$this->addColumn('url_rewrite_id', array(
|
40 |
-
'header' => $this->__('ID'),
|
41 |
-
'width' => '50px',
|
42 |
-
'index' => 'url_rewrite_id'
|
43 |
-
));
|
44 |
-
|
45 |
-
if (!Mage::app()->isSingleStoreMode()) {
|
46 |
-
$this->addColumn('store_id', array(
|
47 |
-
'header' => $this->__('Store View'),
|
48 |
-
'width' => '200px',
|
49 |
-
'index' => 'store_id',
|
50 |
-
'type' => 'store',
|
51 |
-
'store_view' => true,
|
52 |
-
));
|
53 |
-
}
|
54 |
-
|
55 |
-
$this->addColumn('is_system', array(
|
56 |
-
'header' =>$this->__('Type'),
|
57 |
-
'width' => '50px',
|
58 |
-
'index' => 'is_system',
|
59 |
-
'type' => 'options',
|
60 |
-
'options' => array(
|
61 |
-
1 => $this->__('System'),
|
62 |
-
0 => $this->__('Custom')
|
63 |
-
),
|
64 |
-
));
|
65 |
-
|
66 |
-
$this->addColumn('id_path', array(
|
67 |
-
'header' => $this->__('ID Path'),
|
68 |
-
'width' => '50px',
|
69 |
-
'index' => 'id_path'
|
70 |
-
));
|
71 |
-
$this->addColumn('request_path', array(
|
72 |
-
'header' => $this->__('Request Path'),
|
73 |
-
'width' => '50px',
|
74 |
-
'index' => 'request_path'
|
75 |
-
));
|
76 |
-
$this->addColumn('target_path', array(
|
77 |
-
'header' => $this->__('Target Path'),
|
78 |
-
'width' => '50px',
|
79 |
-
'index' => 'target_path'
|
80 |
-
));
|
81 |
-
$this->addColumn('options', array(
|
82 |
-
'header' => $this->__('Options'),
|
83 |
-
'width' => '50px',
|
84 |
-
'index' => 'options'
|
85 |
-
));
|
86 |
-
$this->addColumn('actions', array(
|
87 |
-
'header' => $this->__('Action'),
|
88 |
-
'width' => '15px',
|
89 |
-
'sortable' => false,
|
90 |
-
'filter' => false,
|
91 |
-
'type' => 'action',
|
92 |
-
'actions' => array(
|
93 |
-
array(
|
94 |
-
'url' => $this->getUrl('*/*/edit') . 'id/$url_rewrite_id',
|
95 |
-
'caption' => $this->__('Edit'),
|
96 |
-
),
|
97 |
-
)
|
98 |
-
));
|
99 |
-
$this->addExportType('*/*/exportCsv', $this->__('CSV'));
|
100 |
-
$this->addExportType('*/*/exportXml', $this->__('XML'));
|
101 |
-
return parent::_prepareColumns();
|
102 |
-
}
|
103 |
-
|
104 |
-
|
105 |
-
protected function _prepareMassaction()
|
106 |
-
{
|
107 |
-
$this->setMassactionIdField('entity_id');
|
108 |
-
$this->getMassactionBlock()->setFormFieldName('product');
|
109 |
-
|
110 |
-
$this->getMassactionBlock()->addItem('delete', array(
|
111 |
-
'label'=> Mage::helper('catalog')->__('Delete'),
|
112 |
-
'url' => $this->getUrl('*/*/massDelete'),
|
113 |
-
'confirm' => Mage::helper('catalog')->__('Are you sure?')
|
114 |
-
));
|
115 |
-
|
116 |
-
// $statuses = Mage::getSingleton('catalog/product_status')->getOptionArray();
|
117 |
-
//
|
118 |
-
// array_unshift($statuses, array('label'=>'', 'value'=>''));
|
119 |
-
// $this->getMassactionBlock()->addItem('status', array(
|
120 |
-
// 'label'=> Mage::helper('catalog')->__('Change status'),
|
121 |
-
// 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
122 |
-
// 'additional' => array(
|
123 |
-
// 'visibility' => array(
|
124 |
-
// 'name' => 'status',
|
125 |
-
// 'type' => 'select',
|
126 |
-
// 'class' => 'required-entry',
|
127 |
-
// 'label' => Mage::helper('catalog')->__('Status'),
|
128 |
-
// 'values' => $statuses
|
129 |
-
// )
|
130 |
-
// )
|
131 |
-
// ));
|
132 |
-
|
133 |
-
Mage::dispatchEvent('adminhtml_catalog_product_grid_prepare_massaction', array('block' => $this));
|
134 |
-
return $this;
|
135 |
-
}
|
136 |
-
|
137 |
-
}
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Mklauza/CustomProductUrls/Helper/Data.php
CHANGED
@@ -22,9 +22,9 @@
|
|
22 |
|
23 |
class Mklauza_CustomProductUrls_Helper_Data extends Mage_Core_Helper_Abstract {
|
24 |
|
25 |
-
private $_attributesCollection;
|
26 |
-
private $_productAttributes;
|
27 |
-
private $_patternChunks;
|
28 |
|
29 |
public function getIsEnabled() {
|
30 |
return Mage::getStoreConfigFlag('mklauza_customproducturls/general/is_active');
|
@@ -38,124 +38,130 @@ class Mklauza_CustomProductUrls_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
38 |
return Mage::getStoreConfig('mklauza_customproducturls/general/pattern');
|
39 |
}
|
40 |
|
41 |
-
public function getAttributesCollection() {
|
42 |
-
if($this->_attributesCollection === null) {
|
43 |
-
$this->_attributesCollection = Mage::getResourceModel('catalog/product_attribute_collection')
|
44 |
-
->addVisibleFilter('is_visible_on_front', array('=' => '1'))
|
45 |
-
->addFieldTofilter('attribute_code', array('neq' => 'url_key'));
|
46 |
-
}
|
47 |
-
return $this->_attributesCollection;
|
48 |
-
}
|
49 |
-
|
50 |
-
public function getProductAttributes() {
|
51 |
-
if($this->_productAttributes === null) {
|
52 |
-
|
53 |
-
$attributes = array();
|
54 |
-
foreach ($this->getAttributesCollection() as $productAttr) { /** @var Mage_Catalog_Model_Resource_Eav_Attribute $productAttr */
|
55 |
-
$attributes[$productAttr->getAttributeCode()] = $this->jsQuoteEscape($productAttr->getFrontendLabel());
|
56 |
-
}
|
57 |
-
$this->_productAttributes = $attributes;
|
58 |
-
}
|
59 |
-
return $this->_productAttributes;
|
60 |
-
}
|
61 |
-
|
62 |
-
public function extractChunks($urlPattern = '') {
|
63 |
-
$regex = '/(\{(\w+)\})?([^\{\}]+)?/';
|
64 |
-
|
65 |
-
$chunks = array();
|
66 |
-
$doesMatch = true;
|
67 |
-
while(strlen($urlPattern) && $doesMatch)
|
68 |
-
{
|
69 |
-
$matches = array();
|
70 |
-
$doesMatch = preg_match($regex, $urlPattern, $matches);
|
71 |
-
if(!empty($matches[2])) {
|
72 |
-
$chunks[] = array('value' => $matches[2], 'type' => 'attribute');
|
73 |
-
}
|
74 |
-
if(!empty($matches[3])) {
|
75 |
-
$chunks[] = array('value' => $matches[3], 'type' => 'text');
|
76 |
-
}
|
77 |
-
|
78 |
-
$urlPattern = str_replace($matches[0], '', $urlPattern);
|
79 |
-
}
|
80 |
-
|
81 |
-
return $chunks;
|
82 |
-
}
|
83 |
-
|
84 |
-
public function getPatternChunks($urlPattern) {
|
85 |
-
if($this->_patternChunks === null) {
|
86 |
-
$this->_patternChunks = $this->extractChunks($urlPattern);
|
87 |
-
}
|
88 |
-
return $this->_patternChunks;
|
89 |
-
}
|
90 |
-
|
91 |
-
private function _getPatternAttributes() {
|
92 |
-
$chunks = $this->getPatternChunks();
|
93 |
-
foreach($chunks as $chunk) {
|
94 |
-
if($chunk['type'] === 'attribute') {
|
95 |
-
$attributes[] = $chunk['value'];
|
96 |
-
}
|
97 |
-
}
|
98 |
-
$attributes = array_flip($attributes);
|
99 |
-
foreach($attributes as $_code => $val) {
|
100 |
-
$attribute = Mage::getSingleton('eav/config')
|
101 |
-
->getAttribute(Mage_Catalog_Model_Product::ENTITY, $_code);
|
102 |
-
if ($attribute->usesSource()) {
|
103 |
-
$htmlOptions = $attribute->getSource()->getAllOptions(false);
|
104 |
-
if($htmlOptions && is_array($htmlOptions) && count($htmlOptions))
|
105 |
-
{
|
106 |
-
$options = array();
|
107 |
-
foreach($htmlOptions as $option) {
|
108 |
-
$options[$option['value']] = $option['label'];
|
109 |
-
}
|
110 |
-
$attributes[$_code]= $options;
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
return $attributes;
|
115 |
-
}
|
116 |
-
|
117 |
-
public function prepareUrlKey($productId, $urlPattern, $storeId) {
|
118 |
-
$chunks = $this->getPatternChunks($urlPattern);
|
119 |
-
$patternAttributes = $this->_getPatternAttributes();
|
120 |
-
|
121 |
-
foreach($patternAttributes as $code => &$value) {
|
122 |
-
$rawValue = Mage::getModel('catalog/product')->getResource()->getAttributeRawValue($productId, $code, $storeId);
|
123 |
-
// options
|
124 |
-
if(is_array($value)) {
|
125 |
-
$textOption = $value[$rawValue];
|
126 |
-
$value = $textOption;
|
127 |
-
} elseif($code === 'price') {
|
128 |
-
$value = number_format($rawValue, 2);
|
129 |
-
} else {
|
130 |
-
$value = $rawValue;
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
134 |
-
$url_str = '';
|
135 |
-
foreach($chunks as $chunk) {
|
136 |
-
if($chunk['type'] === 'attribute') {
|
137 |
-
$attrCode = $chunk['value'];
|
138 |
-
$url_str .= $patternAttributes[$attrCode];
|
139 |
-
} elseif($chunk['type'] === 'text') {
|
140 |
-
$url_str .= $chunk['value'];
|
141 |
-
}
|
142 |
-
}
|
143 |
-
|
144 |
-
return $url_str;
|
145 |
-
}
|
146 |
-
|
147 |
-
public function getRandomExample($pattern) {
|
148 |
-
$storeId = Mage::app()->getStore()->getStoreId();
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
$
|
157 |
-
$
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
}
|
22 |
|
23 |
class Mklauza_CustomProductUrls_Helper_Data extends Mage_Core_Helper_Abstract {
|
24 |
|
25 |
+
// private $_attributesCollection;
|
26 |
+
// private $_productAttributes;
|
27 |
+
// private $_patternChunks;
|
28 |
|
29 |
public function getIsEnabled() {
|
30 |
return Mage::getStoreConfigFlag('mklauza_customproducturls/general/is_active');
|
38 |
return Mage::getStoreConfig('mklauza_customproducturls/general/pattern');
|
39 |
}
|
40 |
|
41 |
+
// public function getAttributesCollection() {
|
42 |
+
// if($this->_attributesCollection === null) {
|
43 |
+
// $this->_attributesCollection = Mage::getResourceModel('catalog/product_attribute_collection')
|
44 |
+
// ->addVisibleFilter('is_visible_on_front', array('=' => '1'))
|
45 |
+
// ->addFieldTofilter('attribute_code', array('neq' => 'url_key'));
|
46 |
+
// }
|
47 |
+
// return $this->_attributesCollection;
|
48 |
+
// }
|
49 |
+
//
|
50 |
+
// public function getProductAttributes() {
|
51 |
+
// if($this->_productAttributes === null) {
|
52 |
+
//
|
53 |
+
// $attributes = array();
|
54 |
+
// foreach ($this->getAttributesCollection() as $productAttr) { /** @var Mage_Catalog_Model_Resource_Eav_Attribute $productAttr */
|
55 |
+
// $attributes[$productAttr->getAttributeCode()] = $this->jsQuoteEscape($productAttr->getFrontendLabel());
|
56 |
+
// }
|
57 |
+
// $this->_productAttributes = $attributes;
|
58 |
+
// }
|
59 |
+
// return $this->_productAttributes;
|
60 |
+
// }
|
61 |
+
//
|
62 |
+
// public function extractChunks($urlPattern = '') {
|
63 |
+
// $regex = '/(\{(\w+)\})?([^\{\}]+)?/';
|
64 |
+
//
|
65 |
+
// $chunks = array();
|
66 |
+
// $doesMatch = true;
|
67 |
+
// while(strlen($urlPattern) && $doesMatch)
|
68 |
+
// {
|
69 |
+
// $matches = array();
|
70 |
+
// $doesMatch = preg_match($regex, $urlPattern, $matches);
|
71 |
+
// if(!empty($matches[2])) {
|
72 |
+
// $chunks[] = array('value' => $matches[2], 'type' => 'attribute');
|
73 |
+
// }
|
74 |
+
// if(!empty($matches[3])) {
|
75 |
+
// $chunks[] = array('value' => $matches[3], 'type' => 'text');
|
76 |
+
// }
|
77 |
+
//
|
78 |
+
// $urlPattern = str_replace($matches[0], '', $urlPattern);
|
79 |
+
// }
|
80 |
+
//
|
81 |
+
// return $chunks;
|
82 |
+
// }
|
83 |
+
//
|
84 |
+
// public function getPatternChunks($urlPattern) {
|
85 |
+
// if($this->_patternChunks === null) {
|
86 |
+
// $this->_patternChunks = $this->extractChunks($urlPattern);
|
87 |
+
// }
|
88 |
+
// return $this->_patternChunks;
|
89 |
+
// }
|
90 |
+
//
|
91 |
+
// private function _getPatternAttributes() {
|
92 |
+
// $chunks = $this->getPatternChunks();
|
93 |
+
// foreach($chunks as $chunk) {
|
94 |
+
// if($chunk['type'] === 'attribute') {
|
95 |
+
// $attributes[] = $chunk['value'];
|
96 |
+
// }
|
97 |
+
// }
|
98 |
+
// $attributes = array_flip($attributes);
|
99 |
+
// foreach($attributes as $_code => $val) {
|
100 |
+
// $attribute = Mage::getSingleton('eav/config')
|
101 |
+
// ->getAttribute(Mage_Catalog_Model_Product::ENTITY, $_code);
|
102 |
+
// if ($attribute->usesSource()) {
|
103 |
+
// $htmlOptions = $attribute->getSource()->getAllOptions(false);
|
104 |
+
// if($htmlOptions && is_array($htmlOptions) && count($htmlOptions))
|
105 |
+
// {
|
106 |
+
// $options = array();
|
107 |
+
// foreach($htmlOptions as $option) {
|
108 |
+
// $options[$option['value']] = $option['label'];
|
109 |
+
// }
|
110 |
+
// $attributes[$_code]= $options;
|
111 |
+
// }
|
112 |
+
// }
|
113 |
+
// }
|
114 |
+
// return $attributes;
|
115 |
+
// }
|
116 |
+
//
|
117 |
+
// public function prepareUrlKey($productId, $urlPattern, $storeId) {
|
118 |
+
// $chunks = $this->getPatternChunks($urlPattern);
|
119 |
+
// $patternAttributes = $this->_getPatternAttributes();
|
120 |
+
//
|
121 |
+
// foreach($patternAttributes as $code => &$value) {
|
122 |
+
// $rawValue = Mage::getModel('catalog/product')->getResource()->getAttributeRawValue($productId, $code, $storeId);
|
123 |
+
// // options
|
124 |
+
// if(is_array($value)) {
|
125 |
+
// $textOption = $value[$rawValue];
|
126 |
+
// $value = $textOption;
|
127 |
+
// } elseif($code === 'price') {
|
128 |
+
// $value = number_format($rawValue, 2);
|
129 |
+
// } else {
|
130 |
+
// $value = $rawValue;
|
131 |
+
// }
|
132 |
+
// }
|
133 |
+
//
|
134 |
+
// $url_str = '';
|
135 |
+
// foreach($chunks as $chunk) {
|
136 |
+
// if($chunk['type'] === 'attribute') {
|
137 |
+
// $attrCode = $chunk['value'];
|
138 |
+
// $url_str .= $patternAttributes[$attrCode];
|
139 |
+
// } elseif($chunk['type'] === 'text') {
|
140 |
+
// $url_str .= $chunk['value'];
|
141 |
+
// }
|
142 |
+
// }
|
143 |
+
//
|
144 |
+
// return $url_str;
|
145 |
+
// }
|
146 |
+
//
|
147 |
+
// public function getRandomExample($pattern) {
|
148 |
+
// $storeId = Mage::app()->getStore()->getStoreId();
|
149 |
+
////// @test
|
150 |
+
////$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler();
|
151 |
+
////$profiler->setEnabled(true);
|
152 |
+
// // get random product Id
|
153 |
+
// $collection = Mage::getResourceModel('catalog/product_collection')
|
154 |
+
// ->addStoreFilter($storeId)
|
155 |
+
// ->addFieldToFilter('visibility', array('neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE));
|
156 |
+
// $collection->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns('entity_id')->order(new Zend_Db_Expr('RAND()'))->limit(1);
|
157 |
+
// $productId = $collection->getFirstItem()->getId();
|
158 |
+
////// @test
|
159 |
+
////Mage::log(print_r($profiler->getQueryProfiles(), true), null, 'example.log', true);
|
160 |
+
////Mage::log(array($profiler->getTotalNumQueries(), $profiler->getTotalElapsedSecs()), null, 'example.log', true);
|
161 |
+
////$profiler->setEnabled(false);
|
162 |
+
// $url_key = $this->prepareUrlKey($productId, $pattern, $storeId);
|
163 |
+
// $url_key = Mage::getModel('catalog/product_url')->formatUrlKey($url_key);
|
164 |
+
// return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . $url_key . Mage::getStoreConfig('catalog/seo/product_url_suffix');
|
165 |
+
// }
|
166 |
|
167 |
}
|
app/code/community/Mklauza/CustomProductUrls/Model/Adminhtml/Observer.php
CHANGED
@@ -32,49 +32,14 @@ class Mklauza_CustomProductUrls_Model_Adminhtml_Observer {
|
|
32 |
|
33 |
$block->getMassactionBlock()->addItem('mklauza_customproducturls', array(
|
34 |
'label' => 'Set custom URL',
|
35 |
-
// 'url' => $block->getUrl('*/productUrls'),
|
36 |
'url' => $block->getUrl('*/productUrlsMassAction/edit'),
|
37 |
));
|
38 |
|
39 |
-
// $columnId = 'massaction';
|
40 |
-
//
|
41 |
-
// $massactionColumn = array(
|
42 |
-
// 'index' => $block->getMassactionIdField(),
|
43 |
-
// 'filter_index' => $block->getMassactionIdFilter(),
|
44 |
-
// 'type' => 'massaction',
|
45 |
-
// 'name' => $block->getMassactionBlock()->getFormFieldName(),
|
46 |
-
// 'align' => 'center',
|
47 |
-
// 'is_system' => true
|
48 |
-
// );
|
49 |
-
//
|
50 |
-
// if ($block->getNoFilterMassactionColumn()) {
|
51 |
-
// $massactionColumn->setData('filter', false);
|
52 |
-
// }
|
53 |
-
//
|
54 |
-
// // rearrange the columns;
|
55 |
-
// $oldColumns = $block->getColumns();
|
56 |
-
// foreach($oldColumns as $column){
|
57 |
-
// $block->removeColumn($column->getId());
|
58 |
-
// }
|
59 |
-
|
60 |
-
// $block->addColumn($columnId, $massactionColumn);
|
61 |
-
// $block->addColumn('block_id', array(
|
62 |
-
// 'header' => Mage::helper('cms')->__('ID'),
|
63 |
-
// 'width' => '50px',
|
64 |
-
// 'type' => 'number',
|
65 |
-
// 'index' => 'block_id',
|
66 |
-
// ));
|
67 |
-
|
68 |
-
// put back the original columns
|
69 |
-
// foreach($oldColumns as $column){
|
70 |
-
// $block->addColumn($column->getId(),$column->getData());
|
71 |
-
// }
|
72 |
-
|
73 |
return $this;
|
74 |
}
|
75 |
}
|
76 |
|
77 |
-
public function addClearPermanentRedirectsButton(Varien_Event_Observer $observer) {
|
78 |
$block = $observer->getEvent()->getBlock();
|
79 |
if (Mage::helper('mklauza_customproducturls')->getIsEnabled() && $block instanceof Mage_Adminhtml_Block_Urlrewrite) {
|
80 |
$block->addButton('clear', array(
|
32 |
|
33 |
$block->getMassactionBlock()->addItem('mklauza_customproducturls', array(
|
34 |
'label' => 'Set custom URL',
|
|
|
35 |
'url' => $block->getUrl('*/productUrlsMassAction/edit'),
|
36 |
));
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
return $this;
|
39 |
}
|
40 |
}
|
41 |
|
42 |
+
public function addClearPermanentRedirectsButton(Varien_Event_Observer $observer) { // adminhtml_block_html_before
|
43 |
$block = $observer->getEvent()->getBlock();
|
44 |
if (Mage::helper('mklauza_customproducturls')->getIsEnabled() && $block instanceof Mage_Adminhtml_Block_Urlrewrite) {
|
45 |
$block->addButton('clear', array(
|
app/code/community/Mklauza/CustomProductUrls/Model/Catalog/Product/Url.php
CHANGED
@@ -30,7 +30,7 @@ class Mklauza_CustomProductUrls_Model_Catalog_Product_Url extends Mage_Catalog_M
|
|
30 |
*/
|
31 |
public function formatUrlKey($str)
|
32 |
{
|
33 |
-
// added '/'
|
34 |
$urlKey = preg_replace('#[^0-9a-z\/.]+#i', '-', Mage::helper('catalog/product_url')->format($str));
|
35 |
$urlKey = strtolower($urlKey);
|
36 |
$urlKey = trim($urlKey, '-');
|
30 |
*/
|
31 |
public function formatUrlKey($str)
|
32 |
{
|
33 |
+
// added '/' character
|
34 |
$urlKey = preg_replace('#[^0-9a-z\/.]+#i', '-', Mage::helper('catalog/product_url')->format($str));
|
35 |
$urlKey = strtolower($urlKey);
|
36 |
$urlKey = trim($urlKey, '-');
|
app/code/community/Mklauza/CustomProductUrls/Model/Catalog/Resource/Product/Action.php
CHANGED
@@ -54,7 +54,9 @@ class Mklauza_CustomProductUrls_Model_Catalog_Resource_Product_Action extends Ma
|
|
54 |
// Mage::register('save_rewrite_history', $origSaveHistory);
|
55 |
Mage::getSingleton('core/config')->saveConfig('catalog/seo/save_rewrites_history', (bool) $urlKeyCreateRedirect);
|
56 |
Mage::app()->getConfig()->reinit();
|
57 |
-
|
|
|
|
|
58 |
$this->_getWriteAdapter()->beginTransaction();
|
59 |
try {
|
60 |
$attribute = $this->getAttribute('url_key');
|
@@ -72,7 +74,8 @@ class Mklauza_CustomProductUrls_Model_Catalog_Resource_Product_Action extends Ma
|
|
72 |
// $rewriteAttribute = $this->getAttribute('save_rewrites_history');
|
73 |
// $this->_saveAttributeValue($object, $rewriteAttribute, $urlKeyCreateRedirect);
|
74 |
|
75 |
-
$value = $
|
|
|
76 |
// collect data for save
|
77 |
$this->_saveAttributeValue($object, $attribute, $value);
|
78 |
// save collected data every 1000 rows
|
54 |
// Mage::register('save_rewrite_history', $origSaveHistory);
|
55 |
Mage::getSingleton('core/config')->saveConfig('catalog/seo/save_rewrites_history', (bool) $urlKeyCreateRedirect);
|
56 |
Mage::app()->getConfig()->reinit();
|
57 |
+
$urlModel = Mage::getModel('catalog/product_url');
|
58 |
+
$patternObject = Mage::getSingleton('mklauza_customproducturls/pattern')->setPattern($urlPattern);
|
59 |
+
|
60 |
$this->_getWriteAdapter()->beginTransaction();
|
61 |
try {
|
62 |
$attribute = $this->getAttribute('url_key');
|
74 |
// $rewriteAttribute = $this->getAttribute('save_rewrites_history');
|
75 |
// $this->_saveAttributeValue($object, $rewriteAttribute, $urlKeyCreateRedirect);
|
76 |
|
77 |
+
$value = $patternObject->prepareUrlKey($entityId, $storeId);
|
78 |
+
$value = $urlModel->formatUrlKey($value);
|
79 |
// collect data for save
|
80 |
$this->_saveAttributeValue($object, $attribute, $value);
|
81 |
// save collected data every 1000 rows
|
app/code/community/Mklauza/CustomProductUrls/Model/Catalog/Resource/Product/Attribute/Backend/_Urlkey.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Marcin Klauza - Magento developer
|
4 |
-
* http://www.marcinklauza.com
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to marcinklauza@gmail.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* @category Mklauza
|
17 |
-
* @package Mklauza_CustomProductUrls
|
18 |
-
* @author Marcin Klauza <marcinklauza@gmail.com>
|
19 |
-
* @copyright Copyright (c) 2015 (Marcin Klauza)
|
20 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
-
*/
|
22 |
-
|
23 |
-
class Mklauza_CustomProductUrls_Model_Catalog_Resource_Product_Attribute_Backend_Urlkey
|
24 |
-
extends Mage_Catalog_Model_Product_Attribute_Backend_Urlkey
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Before save
|
28 |
-
*
|
29 |
-
* @param Varien_Object $object
|
30 |
-
* @return Mage_Catalog_Model_Resource_Product_Attribute_Backend_Urlkey
|
31 |
-
* @overridden
|
32 |
-
*/
|
33 |
-
public function beforeSave($object)
|
34 |
-
{
|
35 |
-
$attributeName = $this->getAttribute()->getName();
|
36 |
-
|
37 |
-
$urlKey = $object->getData($attributeName);
|
38 |
-
if ($urlKey == '') {
|
39 |
-
$urlKey = Mage::helper('mklauza_customproducturls')->prepareUrlKey($object);
|
40 |
-
}
|
41 |
-
$object->setData($attributeName, $object->formatUrlKey($urlKey));
|
42 |
-
|
43 |
-
return $this;
|
44 |
-
}
|
45 |
-
|
46 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Mklauza/CustomProductUrls/Model/Pattern.php
ADDED
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Marcin Klauza - Magento developer
|
4 |
+
* http://www.marcinklauza.com
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to marcinklauza@gmail.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Mklauza
|
17 |
+
* @package Mklauza_CustomProductUrls
|
18 |
+
* @author Marcin Klauza <marcinklauza@gmail.com>
|
19 |
+
* @copyright Copyright (c) 2015 (Marcin Klauza)
|
20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Mklauza_CustomProductUrls_Model_Pattern extends Varien_Object {
|
24 |
+
|
25 |
+
private $_attributesCollection;
|
26 |
+
private $_productAttributes;
|
27 |
+
private $_attributesChunks;
|
28 |
+
private $_patternChunks;
|
29 |
+
|
30 |
+
// public function __construct() {
|
31 |
+
// if( $this->getPattern() === null) {
|
32 |
+
// $this->setPattern($this->_helper()->getConfigPattern());
|
33 |
+
// }
|
34 |
+
// }
|
35 |
+
|
36 |
+
private function getAttributesCollection() {
|
37 |
+
$this->_attributesCollection = json_decode(Mage::app()->getCache()->load('mklauza_product_attributes_collection'), true);
|
38 |
+
if(!$this->_attributesCollection) {
|
39 |
+
$this->_attributesCollection = Mage::getResourceModel('catalog/product_attribute_collection')
|
40 |
+
->addVisibleFilter('is_visible_on_front', array('=' => '1'))
|
41 |
+
->addFieldTofilter('attribute_code', array('neq' => 'url_key'));
|
42 |
+
Mage::app()->getCache()->remove('mklauza_cusomproducturls_product_attributes_collection');
|
43 |
+
Mage::app()->getCache()->save(
|
44 |
+
json_encode($this->_attributesCollection),
|
45 |
+
"mklauza_cusomproducturls_product_attributes_collection",
|
46 |
+
array("mklauza_cusomproducturls"),
|
47 |
+
3*60
|
48 |
+
);
|
49 |
+
}
|
50 |
+
return $this->_attributesCollection;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getAllProductAttributes() {
|
54 |
+
if(!$this->_productAttributes) {
|
55 |
+
$attributes = array();
|
56 |
+
foreach ($this->getAttributesCollection() as $productAttr) { /** @var Mage_Catalog_Model_Resource_Eav_Attribute $productAttr */
|
57 |
+
$attributes[$productAttr->getAttributeCode()] = $productAttr->getFrontendLabel();//Mage::helper('core')->jsQuoteEscape($productAttr->getFrontendLabel());
|
58 |
+
}
|
59 |
+
$this->_productAttributes = $attributes;
|
60 |
+
}
|
61 |
+
return $this->_productAttributes;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getAllProductAttributesChunks() {
|
65 |
+
if($this->_attributesChunks == null) {
|
66 |
+
$attributes = $this->getAllProductAttributes();
|
67 |
+
$patternChunks = $this->getPatternChunks();
|
68 |
+
|
69 |
+
foreach($patternChunks as $chunk) {
|
70 |
+
if($chunk['type'] === 'attribute') {
|
71 |
+
$attrId = $chunk['value'];
|
72 |
+
unset($attributes[$attrId]);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
$this->_attributesChunks = array();
|
77 |
+
foreach($attributes as $code => $label) {
|
78 |
+
$this->_attributesChunks[] = array('value' => $code, 'type' => 'attribute');
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
return $this->_attributesChunks;
|
83 |
+
}
|
84 |
+
|
85 |
+
// ----------------------------------------------------------------------
|
86 |
+
|
87 |
+
// public function getPattern() {
|
88 |
+
// if(!$this->getData('pattern')) {
|
89 |
+
// throw new Exception('Url Pattern not specified. Set pattern first.');
|
90 |
+
// }
|
91 |
+
// return $this->getData('pattern');
|
92 |
+
// }
|
93 |
+
|
94 |
+
private function _getPatternChunks() {
|
95 |
+
$urlPattern = $this->getPattern();
|
96 |
+
|
97 |
+
$regex = '/(\{(\w+)\})?([^\{\}]+)?/';
|
98 |
+
|
99 |
+
$chunks = array();
|
100 |
+
$doesMatch = true;
|
101 |
+
while(strlen($urlPattern) && $doesMatch)
|
102 |
+
{
|
103 |
+
$matches = array();
|
104 |
+
$doesMatch = preg_match($regex, $urlPattern, $matches);
|
105 |
+
if(!empty($matches[2])) {
|
106 |
+
$chunks[] = array('value' => $matches[2], 'type' => 'attribute');
|
107 |
+
}
|
108 |
+
if(!empty($matches[3])) {
|
109 |
+
$chunks[] = array('value' => $matches[3], 'type' => 'text');
|
110 |
+
}
|
111 |
+
|
112 |
+
$urlPattern = str_replace($matches[0], '', $urlPattern);
|
113 |
+
}
|
114 |
+
|
115 |
+
return $chunks;
|
116 |
+
}
|
117 |
+
|
118 |
+
public function getPatternChunks() {
|
119 |
+
if($this->_patternChunks === null) {
|
120 |
+
$this->_patternChunks = $this->_getPatternChunks();
|
121 |
+
}
|
122 |
+
return $this->_patternChunks;
|
123 |
+
}
|
124 |
+
|
125 |
+
private function getPatternAttributesValues() {
|
126 |
+
$chunks = $this->getPatternChunks();
|
127 |
+
foreach($chunks as $chunk) {
|
128 |
+
if($chunk['type'] === 'attribute') {
|
129 |
+
$attributes[] = $chunk['value'];
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$allAttributes = array();
|
133 |
+
foreach($this->getAttributesCollection() as $_attribute) {
|
134 |
+
$allAttributes[$_attribute->getAttributeCode()] = $_attribute;
|
135 |
+
}
|
136 |
+
$attributes = array_flip($attributes);
|
137 |
+
foreach($attributes as $_code => $val) {
|
138 |
+
$attribute = $allAttributes[$_code];//Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, $_code);
|
139 |
+
if ($attribute->usesSource()) {
|
140 |
+
$htmlOptions = $attribute->getSource()->getAllOptions(false);
|
141 |
+
if($htmlOptions && is_array($htmlOptions) && count($htmlOptions))
|
142 |
+
{
|
143 |
+
$options = array();
|
144 |
+
foreach($htmlOptions as $option) {
|
145 |
+
$options[$option['value']] = $option['label'];
|
146 |
+
}
|
147 |
+
$attributes[$_code]= $options;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
return $attributes;
|
152 |
+
}
|
153 |
+
|
154 |
+
public function prepareUrlKey($productId, $storeId) {
|
155 |
+
$chunks = $this->getPatternChunks();
|
156 |
+
$patternAttributes = $this->getPatternAttributesValues();
|
157 |
+
|
158 |
+
foreach($patternAttributes as $code => &$value) {
|
159 |
+
$rawValue = Mage::getModel('catalog/product')->getResource()->getAttributeRawValue($productId, $code, $storeId);
|
160 |
+
// options
|
161 |
+
if(is_array($value)) {
|
162 |
+
$textOption = $value[$rawValue];
|
163 |
+
$value = $textOption;
|
164 |
+
} elseif($code === 'price') {
|
165 |
+
$value = number_format($rawValue, 2);
|
166 |
+
} else {
|
167 |
+
$value = $rawValue;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
$url_str = '';
|
172 |
+
foreach($chunks as $chunk) {
|
173 |
+
if($chunk['type'] === 'attribute') {
|
174 |
+
$attrCode = $chunk['value'];
|
175 |
+
$url_str .= $patternAttributes[$attrCode];
|
176 |
+
} elseif($chunk['type'] === 'text') {
|
177 |
+
$url_str .= $chunk['value'];
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
return $url_str;
|
182 |
+
}
|
183 |
+
|
184 |
+
public function getRandomExample() {
|
185 |
+
$storeId = Mage::app()->getStore()->getStoreId();
|
186 |
+
//// @test
|
187 |
+
//$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler();
|
188 |
+
//$profiler->setEnabled(true);
|
189 |
+
// get random product Id
|
190 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
191 |
+
->addStoreFilter($storeId)
|
192 |
+
->addFieldToFilter('visibility', array('neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE));
|
193 |
+
$collection->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns('entity_id')->order(new Zend_Db_Expr('RAND()'))->limit(1);
|
194 |
+
$productId = $collection->getFirstItem()->getId();
|
195 |
+
//// @test
|
196 |
+
//Mage::log(print_r($profiler->getQueryProfiles(), true), null, 'example.log', true);
|
197 |
+
//Mage::log(array($profiler->getTotalNumQueries(), $profiler->getTotalElapsedSecs()), null, 'example.log', true);
|
198 |
+
//$profiler->setEnabled(false);
|
199 |
+
$url_key = $this->prepareUrlKey($productId, $storeId);
|
200 |
+
$url_key = Mage::getModel('catalog/product_url')->formatUrlKey($url_key);
|
201 |
+
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . $url_key . Mage::getStoreConfig('catalog/seo/product_url_suffix');
|
202 |
+
}
|
203 |
+
}
|
app/code/community/Mklauza/CustomProductUrls/controllers/Adminhtml/Catalog/Product/Action/ProductUrlsMassActionController.php
CHANGED
@@ -32,11 +32,11 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
32 |
|
33 |
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
public function editAction()
|
42 |
{
|
@@ -47,7 +47,7 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
47 |
$this->loadLayout();
|
48 |
$this->_setActiveMenu('catalog/product');
|
49 |
|
50 |
-
$formBlock = $this->getLayout()->createBlock('mklauza_customproducturls/
|
51 |
|
52 |
$this->_title('Custom Product Urls')->_addContent($formBlock);
|
53 |
$this->renderLayout();
|
@@ -58,6 +58,10 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
58 |
*/
|
59 |
public function saveAction()
|
60 |
{
|
|
|
|
|
|
|
|
|
61 |
if (!$this->_validateProducts()) {
|
62 |
$this->_getSession()->addError($this->__('Validation failed.'));
|
63 |
return $this->_redirectReferer();
|
@@ -66,9 +70,10 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
66 |
/* Collect Data */
|
67 |
$pattern = $this->getRequest()->getParam('pattern', '');
|
68 |
$urlKeyCreateRedirect = (int) $this->getRequest()->getParam('url_key_create_redirect');
|
|
|
69 |
|
70 |
try {
|
71 |
-
$storeId = $this->
|
72 |
|
73 |
$attribute = Mage::getSingleton('eav/config')
|
74 |
->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'url_key');
|
@@ -78,16 +83,17 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
78 |
|
79 |
Mage::getSingleton('mklauza_customproducturls/catalog_resource_product_action')
|
80 |
->updateUrlKeyAttributes(
|
81 |
-
$this->
|
82 |
$pattern,
|
83 |
$urlKeyCreateRedirect,
|
84 |
$storeId
|
85 |
);
|
86 |
-
|
87 |
-
|
|
|
88 |
|
89 |
$this->_getSession()->addSuccess(
|
90 |
-
$this->__('Total of %d record(s) were updated', count($this->
|
91 |
);
|
92 |
}
|
93 |
catch (Mage_Core_Exception $e) {
|
@@ -96,14 +102,13 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
96 |
catch (Exception $e) {
|
97 |
$this->_getSession()->addException($e, $this->__('An error occurred while updating the product(s) attributes.'));
|
98 |
}
|
99 |
-
|
100 |
-
|
101 |
-
//
|
102 |
-
// $this->_setActiveMenu('catalog/product');
|
103 |
//
|
104 |
-
|
105 |
-
//
|
106 |
-
|
107 |
}
|
108 |
|
109 |
/**
|
@@ -114,7 +119,7 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
114 |
protected function _validateProducts()
|
115 |
{
|
116 |
$error = false;
|
117 |
-
$productIds = $this->
|
118 |
|
119 |
if (!is_array($productIds)) {
|
120 |
$error = $this->__('Please select products for attributes update');
|
@@ -135,7 +140,7 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
135 |
*
|
136 |
* @return Mage_Adminhtml_Helper_Catalog_Product_Edit_Action_Attribute
|
137 |
*/
|
138 |
-
protected function
|
139 |
{
|
140 |
return Mage::helper('adminhtml/catalog_product_edit_action_attribute');
|
141 |
}
|
@@ -159,7 +164,7 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
159 |
try {
|
160 |
if ($attributesData) {
|
161 |
$dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
162 |
-
$storeId = $this->
|
163 |
|
164 |
foreach ($attributesData as $attributeCode => $value) {
|
165 |
$attribute = Mage::getSingleton('eav/config')
|
@@ -197,9 +202,9 @@ class Mklauza_CustomProductUrls_Adminhtml_Catalog_Product_Action_ProductUrlsMass
|
|
197 |
try {
|
198 |
$write->beginTransaction();
|
199 |
$table = Mage::getSingleton('core/resource')->getTableName('core/url_rewrite');
|
200 |
-
$write->
|
201 |
$write->commit();
|
202 |
-
$this->_getSession()->addSuccess($this->__('Successfully
|
203 |
} catch(Exception $e) {
|
204 |
$write->rollback();
|
205 |
$this->_getSession()->addException($e, $this->__('An error occurred while clearing url redirects.<br/>' . $e->getMessage()));
|
32 |
|
33 |
}
|
34 |
|
35 |
+
protected function _construct()
|
36 |
+
{
|
37 |
+
// Define module dependent translate
|
38 |
+
$this->setUsedModuleName('Mage_Catalog');
|
39 |
+
}
|
40 |
|
41 |
public function editAction()
|
42 |
{
|
47 |
$this->loadLayout();
|
48 |
$this->_setActiveMenu('catalog/product');
|
49 |
|
50 |
+
$formBlock = $this->getLayout()->createBlock('mklauza_customproducturls/adminhtml_form_massaction');
|
51 |
|
52 |
$this->_title('Custom Product Urls')->_addContent($formBlock);
|
53 |
$this->renderLayout();
|
58 |
*/
|
59 |
public function saveAction()
|
60 |
{
|
61 |
+
// @test
|
62 |
+
//$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler();
|
63 |
+
//$profiler->setEnabled(true);
|
64 |
+
|
65 |
if (!$this->_validateProducts()) {
|
66 |
$this->_getSession()->addError($this->__('Validation failed.'));
|
67 |
return $this->_redirectReferer();
|
70 |
/* Collect Data */
|
71 |
$pattern = $this->getRequest()->getParam('pattern', '');
|
72 |
$urlKeyCreateRedirect = (int) $this->getRequest()->getParam('url_key_create_redirect');
|
73 |
+
$reindexCatalogUrls = $this->getRequest()->getParam('reindex', '');
|
74 |
|
75 |
try {
|
76 |
+
$storeId = $this->_helper()->getSelectedStoreId();
|
77 |
|
78 |
$attribute = Mage::getSingleton('eav/config')
|
79 |
->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'url_key');
|
83 |
|
84 |
Mage::getSingleton('mklauza_customproducturls/catalog_resource_product_action')
|
85 |
->updateUrlKeyAttributes(
|
86 |
+
$this->_helper()->getProductIds(),
|
87 |
$pattern,
|
88 |
$urlKeyCreateRedirect,
|
89 |
$storeId
|
90 |
);
|
91 |
+
if(!empty($reindexCatalogUrls)) {
|
92 |
+
Mage::getModel('index/indexer')->getProcessByCode('catalog_url');
|
93 |
+
}
|
94 |
|
95 |
$this->_getSession()->addSuccess(
|
96 |
+
$this->__('Total of %d record(s) were updated', count($this->_helper()->getProductIds()))
|
97 |
);
|
98 |
}
|
99 |
catch (Mage_Core_Exception $e) {
|
102 |
catch (Exception $e) {
|
103 |
$this->_getSession()->addException($e, $this->__('An error occurred while updating the product(s) attributes.'));
|
104 |
}
|
105 |
+
//// @test
|
106 |
+
//Mage::log(print_r($profiler->getQueryProfiles(), true), null, 'queries.log', true);
|
107 |
+
//Mage::log(array($profiler->getTotalNumQueries(), $profiler->getTotalElapsedSecs()), null, 'queries.log', true);
|
|
|
108 |
//
|
109 |
+
//$profiler->setEnabled(false);
|
110 |
+
//die();
|
111 |
+
$this->_redirect('*/catalog_product/', array('store'=>$this->_helper()->getSelectedStoreId()));
|
112 |
}
|
113 |
|
114 |
/**
|
119 |
protected function _validateProducts()
|
120 |
{
|
121 |
$error = false;
|
122 |
+
$productIds = $this->_helper()->getProductIds();
|
123 |
|
124 |
if (!is_array($productIds)) {
|
125 |
$error = $this->__('Please select products for attributes update');
|
140 |
*
|
141 |
* @return Mage_Adminhtml_Helper_Catalog_Product_Edit_Action_Attribute
|
142 |
*/
|
143 |
+
protected function _helper()
|
144 |
{
|
145 |
return Mage::helper('adminhtml/catalog_product_edit_action_attribute');
|
146 |
}
|
164 |
try {
|
165 |
if ($attributesData) {
|
166 |
$dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
167 |
+
$storeId = $this->_helper()->getSelectedStoreId();
|
168 |
|
169 |
foreach ($attributesData as $attributeCode => $value) {
|
170 |
$attribute = Mage::getSingleton('eav/config')
|
202 |
try {
|
203 |
$write->beginTransaction();
|
204 |
$table = Mage::getSingleton('core/resource')->getTableName('core/url_rewrite');
|
205 |
+
$count = $write->exec('DELETE FROM ' . $table . ' WHERE options IS NOT NULL AND is_system = 0');
|
206 |
$write->commit();
|
207 |
+
$this->_getSession()->addSuccess($this->__('Successfully removed %s redirects.', $count));
|
208 |
} catch(Exception $e) {
|
209 |
$write->rollback();
|
210 |
$this->_getSession()->addException($e, $this->__('An error occurred while clearing url redirects.<br/>' . $e->getMessage()));
|
app/code/community/Mklauza/CustomProductUrls/controllers/Adminhtml/ProductUrlsController.php
CHANGED
@@ -23,35 +23,18 @@
|
|
23 |
class Mklauza_CustomProductUrls_Adminhtml_ProductUrlsController extends Mage_Adminhtml_Controller_Action {
|
24 |
|
25 |
public function exampleAction() {
|
|
|
|
|
|
|
26 |
$pattern = $this->getRequest()->getParam('pattern');
|
27 |
-
$
|
|
|
|
|
|
|
|
|
28 |
$data['isSuccess'] = true;
|
29 |
$this->getResponse()->setHeader('Content-type','application/json',true);
|
30 |
$this->getResponse()->setBody(json_encode($data));
|
31 |
}
|
32 |
-
// public function indexAction() {
|
33 |
-
// $this->loadLayout();
|
34 |
-
// $this->_setActiveMenu('system/mklauza_customproducturls');
|
35 |
-
// $this->_title('Custom Product Urls')->_addContent($this->getLayout()->createBlock('mklauza_customproducturls/adminhtml_settingsform'));
|
36 |
-
// $this->renderLayout();
|
37 |
-
// }
|
38 |
-
//
|
39 |
-
// public function saveAction() {
|
40 |
-
// try {
|
41 |
-
// $enabled = $this->getRequest()->getParam('is_active');
|
42 |
-
// Mage::getSingleton('core/config')->saveConfig('mklauza_customproducturls/general/is_active', $enabled, 'default', '0');
|
43 |
-
//
|
44 |
-
// $pattern = $this->getRequest()->getParam('pattern');
|
45 |
-
// Mage::getSingleton('core/config')->saveConfig('mklauza_customproducturls/general/pattern', $pattern, 'default', '');
|
46 |
-
//
|
47 |
-
// $applyToNew = $this->getRequest()->getParam('apply_to_new');
|
48 |
-
// Mage::getSingleton('core/config')->saveConfig('mklauza_customproducturls/general/apply_to_new', $applyToNew, 'default', '0');
|
49 |
-
//
|
50 |
-
// $this->_getSession()->addSuccess($this->__('Successfully saved.'));
|
51 |
-
// } catch (Exception $e) {
|
52 |
-
// $this->_getSession()->addError($e->getMessage());
|
53 |
-
// }
|
54 |
-
// $this->_redirect('*/*/index');
|
55 |
-
// }
|
56 |
|
57 |
}
|
23 |
class Mklauza_CustomProductUrls_Adminhtml_ProductUrlsController extends Mage_Adminhtml_Controller_Action {
|
24 |
|
25 |
public function exampleAction() {
|
26 |
+
// @test
|
27 |
+
//$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler();
|
28 |
+
//$profiler->setEnabled(true);
|
29 |
$pattern = $this->getRequest()->getParam('pattern');
|
30 |
+
$patternObject = Mage::getSingleton('mklauza_customproducturls/pattern');
|
31 |
+
$data['exampleUrl'] = $patternObject->setPattern($pattern)->getRandomExample();
|
32 |
+
//Mage::log(print_r($profiler->getQueryProfiles(), true), null, 'queries.log', true);
|
33 |
+
//Mage::log(array($profiler->getTotalNumQueries(), $profiler->getTotalElapsedSecs()), null, 'queries.log', true);
|
34 |
+
//$profiler->setEnabled(false);
|
35 |
$data['isSuccess'] = true;
|
36 |
$this->getResponse()->setHeader('Content-type','application/json',true);
|
37 |
$this->getResponse()->setBody(json_encode($data));
|
38 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
}
|
app/code/community/Mklauza/CustomProductUrls/etc/adminhtml.xml
CHANGED
@@ -1,42 +1,23 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
<sort_order>200</sort_order>
|
24 |
-
</mklauza_customproducturls>
|
25 |
-
</children>
|
26 |
-
</system>
|
27 |
-
</children>
|
28 |
-
</admin>
|
29 |
-
</resources>
|
30 |
-
</acl>
|
31 |
-
<!-- <menu>
|
32 |
-
<system>
|
33 |
-
<children>
|
34 |
-
<mklauza_customproducturls translate="title" module="mklauza_customproducturls">
|
35 |
-
<title>Custom Product Urls</title>
|
36 |
-
<sort_order>91</sort_order>
|
37 |
-
<action>adminhtml/productUrls/</action>
|
38 |
-
</mklauza_customproducturls>
|
39 |
-
</children>
|
40 |
-
</system>
|
41 |
-
</menu> -->
|
42 |
</config>
|
1 |
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<mklauza_customproducturls translate="title" module="mklauza_customproducturls">
|
12 |
+
<title>Custom Product Urls</title>
|
13 |
+
<sort_order>130</sort_order>
|
14 |
+
</mklauza_customproducturls>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
</config>
|
app/code/community/Mklauza/CustomProductUrls/etc/config.xml
CHANGED
@@ -2,9 +2,10 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Mklauza_CustomProductUrls>
|
5 |
-
<version>0.0.
|
6 |
</Mklauza_CustomProductUrls>
|
7 |
</modules>
|
|
|
8 |
<global>
|
9 |
<blocks>
|
10 |
<mklauza_customproducturls>
|
@@ -23,12 +24,11 @@
|
|
23 |
<catalog>
|
24 |
<rewrite>
|
25 |
<product_url>Mklauza_CustomProductUrls_Model_Catalog_Product_Url</product_url>
|
26 |
-
<!-- Mage_Catalog_Model_Product_Attribute_Backend_Urlkey -->
|
27 |
-
<!--<product_attribute_backend_urlkey>Mklauza_CustomProductUrls_Model_Catalog_Resource_Product_Attribute_Backend_Urlkey</product_attribute_backend_urlkey>-->
|
28 |
</rewrite>
|
29 |
</catalog>
|
30 |
</models>
|
31 |
</global>
|
|
|
32 |
<adminhtml>
|
33 |
|
34 |
<events>
|
@@ -75,14 +75,17 @@
|
|
75 |
</Mklauza_CustomProductUrls>
|
76 |
</modules>
|
77 |
</translate>
|
|
|
78 |
<layout>
|
79 |
<updates>
|
80 |
<Mklauza_CustomProductUrls>
|
81 |
<file>mklauza/product_urls.xml</file>
|
82 |
</Mklauza_CustomProductUrls>
|
83 |
</updates>
|
84 |
-
</layout>
|
|
|
85 |
</adminhtml>
|
|
|
86 |
<admin>
|
87 |
<routers>
|
88 |
<adminhtml>
|
@@ -95,4 +98,15 @@
|
|
95 |
</adminhtml>
|
96 |
</routers>
|
97 |
</admin>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Mklauza_CustomProductUrls>
|
5 |
+
<version>0.0.2</version>
|
6 |
</Mklauza_CustomProductUrls>
|
7 |
</modules>
|
8 |
+
|
9 |
<global>
|
10 |
<blocks>
|
11 |
<mklauza_customproducturls>
|
24 |
<catalog>
|
25 |
<rewrite>
|
26 |
<product_url>Mklauza_CustomProductUrls_Model_Catalog_Product_Url</product_url>
|
|
|
|
|
27 |
</rewrite>
|
28 |
</catalog>
|
29 |
</models>
|
30 |
</global>
|
31 |
+
|
32 |
<adminhtml>
|
33 |
|
34 |
<events>
|
75 |
</Mklauza_CustomProductUrls>
|
76 |
</modules>
|
77 |
</translate>
|
78 |
+
|
79 |
<layout>
|
80 |
<updates>
|
81 |
<Mklauza_CustomProductUrls>
|
82 |
<file>mklauza/product_urls.xml</file>
|
83 |
</Mklauza_CustomProductUrls>
|
84 |
</updates>
|
85 |
+
</layout>
|
86 |
+
|
87 |
</adminhtml>
|
88 |
+
|
89 |
<admin>
|
90 |
<routers>
|
91 |
<adminhtml>
|
98 |
</adminhtml>
|
99 |
</routers>
|
100 |
</admin>
|
101 |
+
|
102 |
+
<default>
|
103 |
+
<mklauza_customproducturls>
|
104 |
+
<general>
|
105 |
+
<is_active>1</is_active>
|
106 |
+
<apply_to_new>1</apply_to_new>
|
107 |
+
<pattern>{name}</pattern>
|
108 |
+
</general>
|
109 |
+
</mklauza_customproducturls>
|
110 |
+
</default>
|
111 |
+
|
112 |
</config>
|
app/code/community/Mklauza/CustomProductUrls/etc/system.xml
CHANGED
@@ -44,7 +44,7 @@
|
|
44 |
<pattern>
|
45 |
<label>Pattern</label>
|
46 |
<frontend_type>text</frontend_type>
|
47 |
-
<frontend_model>mklauza_customproducturls/
|
48 |
<!--<source_model>mklauza/system_config_source_enabledisable</source_model>-->
|
49 |
<sort_order>30</sort_order>
|
50 |
<show_in_default>1</show_in_default>
|
44 |
<pattern>
|
45 |
<label>Pattern</label>
|
46 |
<frontend_type>text</frontend_type>
|
47 |
+
<frontend_model>mklauza_customproducturls/adminhtml_system_config_form_pattern</frontend_model>
|
48 |
<!--<source_model>mklauza/system_config_source_enabledisable</source_model>-->
|
49 |
<sort_order>30</sort_order>
|
50 |
<show_in_default>1</show_in_default>
|
app/design/adminhtml/default/default/layout/mklauza/product_urls.xml
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
-
*
|
|
|
5 |
*
|
6 |
* NOTICE OF LICENSE
|
7 |
*
|
@@ -9,23 +10,35 @@
|
|
9 |
* that is bundled with this package in the file LICENSE.txt.
|
10 |
* It is also available through the world-wide-web at this URL:
|
11 |
* http://opensource.org/licenses/osl-3.0.php
|
|
|
|
|
|
|
12 |
*
|
13 |
-
*
|
14 |
-
*
|
15 |
-
*
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* @category Netzarbeiter
|
19 |
-
* @package Netzarbeiter_GroupsCatalog2
|
20 |
-
* @copyright Copyright (c) 2014 Vinai Kopp http://netzarbeiter.com
|
21 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
22 |
*/
|
23 |
-->
|
24 |
<layout>
|
25 |
-
<
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
</layout>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!--
|
3 |
/**
|
4 |
+
* Marcin Klauza - Magento developer
|
5 |
+
* http://www.marcinklauza.com
|
6 |
*
|
7 |
* NOTICE OF LICENSE
|
8 |
*
|
10 |
* that is bundled with this package in the file LICENSE.txt.
|
11 |
* It is also available through the world-wide-web at this URL:
|
12 |
* http://opensource.org/licenses/osl-3.0.php
|
13 |
+
* If you did not receive a copy of the license and are unable to
|
14 |
+
* obtain it through the world-wide-web, please send an email
|
15 |
+
* to marcinklauza@gmail.com so we can send you a copy immediately.
|
16 |
*
|
17 |
+
* @category Mklauza
|
18 |
+
* @package Mklauza_CustomProductUrls
|
19 |
+
* @author Marcin Klauza <marcinklauza@gmail.com>
|
20 |
+
* @copyright Copyright (c) 2015 (Marcin Klauza)
|
21 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
|
|
|
|
|
|
|
|
22 |
*/
|
23 |
-->
|
24 |
<layout>
|
25 |
+
<adminhtml_producturlsmassaction_edit>
|
26 |
+
<reference name="head">
|
27 |
+
<action method="addItem"><type>js_css</type><name>mklauza_customproducturls/template.css</name></action>
|
28 |
+
<action method="addItem"><type>js_css</type><name>mklauza_customproducturls/loadingdots.css</name></action>
|
29 |
+
<action method="addJs"><script>mklauza_customproducturls/jquery-1.11.2.min.js</script></action>
|
30 |
+
<action method="addJs"><script>mklauza_customproducturls/jquery-ui.min.js</script></action>
|
31 |
+
<action method="addJs"><script>mklauza_customproducturls/template.js</script></action>
|
32 |
+
</reference>
|
33 |
+
</adminhtml_producturlsmassaction_edit>
|
34 |
+
|
35 |
+
<adminhtml_system_config_edit>
|
36 |
+
<reference name="head">
|
37 |
+
<action method="addItem"><type>js_css</type><name>mklauza_customproducturls/template.css</name></action>
|
38 |
+
<action method="addItem"><type>js_css</type><name>mklauza_customproducturls/loadingdots.css</name></action>
|
39 |
+
<action method="addJs"><script>mklauza_customproducturls/jquery-1.11.2.min.js</script></action>
|
40 |
+
<action method="addJs"><script>mklauza_customproducturls/jquery-ui.min.js</script></action>
|
41 |
+
<action method="addJs"><script>mklauza_customproducturls/template.js</script></action>
|
42 |
+
</reference>
|
43 |
+
</adminhtml_system_config_edit>
|
44 |
</layout>
|
app/design/adminhtml/default/default/template/mklauza/customproducturls/massaction.phtml
CHANGED
@@ -20,228 +20,6 @@
|
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
?>
|
23 |
-
<!--<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css">-->
|
24 |
-
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
|
25 |
-
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
|
26 |
-
<script>jQuery.noConflict();</script>
|
27 |
-
<style>
|
28 |
-
/*@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,300italic,400italic,600italic);
|
29 |
-
@import url(http://fonts.googleapis.com/css?family=Ubuntu+Condensed);*/
|
30 |
-
* {
|
31 |
-
box-sizing: border-box;
|
32 |
-
}
|
33 |
-
.color {
|
34 |
-
color: #19bc9c !important;
|
35 |
-
}
|
36 |
-
html,
|
37 |
-
body {
|
38 |
-
width: 100%;
|
39 |
-
height: 100%;
|
40 |
-
margin: 0;
|
41 |
-
font-family: 'Ubuntu Condensed', sans-serif;
|
42 |
-
background-color: #dddddd;
|
43 |
-
}
|
44 |
-
h1 {
|
45 |
-
text-align: center;
|
46 |
-
margin-bottom: 32px;
|
47 |
-
}
|
48 |
-
div.container {
|
49 |
-
display: block;
|
50 |
-
width: 50%;
|
51 |
-
margin: 32px auto;
|
52 |
-
padding: 16px 32px;
|
53 |
-
background-color: #ffffff;
|
54 |
-
box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
|
55 |
-
}
|
56 |
-
div.inputTags-list {
|
57 |
-
display: inline-block;
|
58 |
-
width: 100%;
|
59 |
-
padding: 6px;
|
60 |
-
margin: 0 0 20px 0;
|
61 |
-
border: 1px solid rgba(25, 188, 156, 0.35);
|
62 |
-
background-color: #f9f9f9;
|
63 |
-
box-shadow: 1px 2px 2px rgba(221, 221, 221, 0.2);
|
64 |
-
border-radius: 4px;
|
65 |
-
}
|
66 |
-
div.inputTags-list span.inputTags-item {
|
67 |
-
position: relative;
|
68 |
-
display: inline-block;
|
69 |
-
margin: 2px;
|
70 |
-
padding: 3px 22px 4px 8px;
|
71 |
-
border-radius: 3px;
|
72 |
-
background-color: #19bc9c;
|
73 |
-
text-align: center;
|
74 |
-
color: #ffffff;
|
75 |
-
opacity: 1;
|
76 |
-
white-space: nowrap;
|
77 |
-
}
|
78 |
-
|
79 |
-
div.inputTags-list.tag-cloud span.inputTags-item {
|
80 |
-
background-color: #ed6502;
|
81 |
-
}
|
82 |
-
div.inputTags-list span.inputTags-item.blocked {
|
83 |
-
background-color: #ed6502;
|
84 |
-
}
|
85 |
-
|
86 |
-
div.inputTags-list span.inputTags-item.is-edit {
|
87 |
-
display: none;
|
88 |
-
}
|
89 |
-
div.inputTags-list span.inputTags-item.is-hidden {
|
90 |
-
display: none !important;
|
91 |
-
}
|
92 |
-
div.inputTags-list span.inputTags-item.is-exists {
|
93 |
-
background-color: rgba(231, 76, 60, 0.7);
|
94 |
-
}
|
95 |
-
div.inputTags-list span.inputTags-item span.value {
|
96 |
-
cursor: default;
|
97 |
-
}
|
98 |
-
div.inputTags-list span.inputTags-item i {
|
99 |
-
position: absolute;
|
100 |
-
top: 50%;
|
101 |
-
right: 6px;
|
102 |
-
font-size: 20px;
|
103 |
-
cursor: pointer;
|
104 |
-
z-index: 10;
|
105 |
-
font-weight: 400;
|
106 |
-
transition: color 0.2s;
|
107 |
-
font-family: sans-serif;
|
108 |
-
transform: translateY(-50%);
|
109 |
-
}
|
110 |
-
div.inputTags-list span.inputTags-item i:hover {
|
111 |
-
color: #e74c3c;
|
112 |
-
}
|
113 |
-
div.inputTags-list input.inputTags-field {
|
114 |
-
border: none;
|
115 |
-
width: auto;
|
116 |
-
white-space: nowrap;
|
117 |
-
margin-left: 4px;
|
118 |
-
background-color: transparent;
|
119 |
-
}
|
120 |
-
div.inputTags-list input.inputTags-field:focus,
|
121 |
-
div.inputTags-list input.inputTags-field:active {
|
122 |
-
outline: none;
|
123 |
-
}
|
124 |
-
div.inputTags-list input.inputTags-field.is-edit {
|
125 |
-
margin: 0 2px;
|
126 |
-
padding: 4px 8px 3px 8px;
|
127 |
-
border: 1px dashed #c4c4c4;
|
128 |
-
border-radius: 4px;
|
129 |
-
}
|
130 |
-
div.inputTags-list ul.inputTags-autocomplete-list {
|
131 |
-
position: absolute;
|
132 |
-
max-height: 192px;
|
133 |
-
margin: 0;
|
134 |
-
padding: 0;
|
135 |
-
list-style-type: none;
|
136 |
-
background-color: #ffffff;
|
137 |
-
border: 1px solid #dddddd;
|
138 |
-
border-radius: 4px;
|
139 |
-
transform: scaleY(0);
|
140 |
-
transform-origin: 50% 0;
|
141 |
-
transition-duration: 0.2s;
|
142 |
-
overflow-y: auto;
|
143 |
-
z-index: 100;
|
144 |
-
opacity: 0;
|
145 |
-
}
|
146 |
-
div.inputTags-list ul.inputTags-autocomplete-list.is-active {
|
147 |
-
opacity: 1;
|
148 |
-
transform: scaleY(1);
|
149 |
-
}
|
150 |
-
div.inputTags-list ul.inputTags-autocomplete-list li {
|
151 |
-
height: 32px;
|
152 |
-
line-height: 32px;
|
153 |
-
padding: 0 16px;
|
154 |
-
transition-duration: 0.3s;
|
155 |
-
cursor: pointer;
|
156 |
-
border-bottom: 1px solid #dddddd;
|
157 |
-
transition-duration: 0.2s;
|
158 |
-
}
|
159 |
-
div.inputTags-list ul.inputTags-autocomplete-list li:last-child {
|
160 |
-
border: none;
|
161 |
-
}
|
162 |
-
div.inputTags-list ul.inputTags-autocomplete-list li:hover {
|
163 |
-
background-color: #19bc9c;
|
164 |
-
color: #ffffff;
|
165 |
-
}
|
166 |
-
div.inputTags-list ul.inputTags-autocomplete-list li.is-disabled {
|
167 |
-
cursor: default;
|
168 |
-
background-color: #f7f7f7;
|
169 |
-
color: initial;
|
170 |
-
}
|
171 |
-
p.inputTags-error {
|
172 |
-
position: relative;
|
173 |
-
margin: 0;
|
174 |
-
padding: 0.5em 1em;
|
175 |
-
color: #ffffff;
|
176 |
-
background-color: rgba(231, 76, 60, 0.7);
|
177 |
-
border-radius: 4px;
|
178 |
-
cursor: pointer;
|
179 |
-
}
|
180 |
-
p.inputTags-error:first-of-type {
|
181 |
-
margin-top: 8px;
|
182 |
-
}
|
183 |
-
p.inputTags-error:after {
|
184 |
-
position: absolute;
|
185 |
-
content: "\000D7";
|
186 |
-
top: 50%;
|
187 |
-
right: 0.5em;
|
188 |
-
transform: translateY(-50%);
|
189 |
-
font-size: 28px;
|
190 |
-
}
|
191 |
-
</style>
|
192 |
-
|
193 |
-
<script lang="Javascript">
|
194 |
-
(function($) {
|
195 |
-
$.fn.closestToOffset = function(offset) {
|
196 |
-
var el = null, elOffset, x = offset.left, y = offset.top, distance, dx, dy, minDistance;
|
197 |
-
this.each(function() {
|
198 |
-
elOffset = $(this).offset();
|
199 |
-
|
200 |
-
if (
|
201 |
-
(x >= elOffset.left) && (x <= elOffset.right) &&
|
202 |
-
(y >= elOffset.top) && (y <= elOffset.bottom)
|
203 |
-
) {
|
204 |
-
el = $(this);
|
205 |
-
return false;
|
206 |
-
}
|
207 |
-
|
208 |
-
var offsets = [[elOffset.left, elOffset.top], [elOffset.right, elOffset.top], [elOffset.left, elOffset.bottom], [elOffset.right, elOffset.bottom]];
|
209 |
-
for (off in offsets) {
|
210 |
-
dx = offsets[off][0] - x;
|
211 |
-
dy = offsets[off][1] - y;
|
212 |
-
distance = Math.sqrt((dx*dx) + (dy*dy));
|
213 |
-
if (minDistance === undefined || distance < minDistance) {
|
214 |
-
minDistance = distance;
|
215 |
-
el = $(this);
|
216 |
-
}
|
217 |
-
}
|
218 |
-
});
|
219 |
-
return el;
|
220 |
-
}
|
221 |
-
})(jQuery);
|
222 |
-
</script>
|
223 |
-
|
224 |
-
<script lang="Javascript">
|
225 |
-
|
226 |
-
serializePattern = function() {
|
227 |
-
var patternParam = '';
|
228 |
-
jQuery('.js-pattern').children().each(function(){
|
229 |
-
if(jQuery(this).hasClass('inputTags-item')) {
|
230 |
-
patternParam += '{'+jQuery(this).data('value')+'}';
|
231 |
-
} else if(jQuery(this).hasClass('inputTags-field')) {
|
232 |
-
patternParam += jQuery(this).val();
|
233 |
-
}
|
234 |
-
});
|
235 |
-
return patternParam;
|
236 |
-
};
|
237 |
-
|
238 |
-
submitChanges = function(url) {
|
239 |
-
patternParam = serializePattern();
|
240 |
-
// console.log(encodeURIComponent(patternParam));
|
241 |
-
var saveRewrite = document.getElementById('url_key_create_redirect').checked == true ? 1 : 0;
|
242 |
-
location.href = url + '?pattern=' + encodeURIComponent(patternParam) + '&url_key_create_redirect=' + saveRewrite ;
|
243 |
-
};
|
244 |
-
</script>
|
245 |
|
246 |
<div class="js-tag-cloud inputTags-list">
|
247 |
<?php echo $this->getAttributesCloudHtml() ?>
|
@@ -253,21 +31,24 @@ p.inputTags-error:after {
|
|
253 |
|
254 |
<div>
|
255 |
<input id="url_key_create_redirect" name="url_key_create_redirect" <?php echo $this->getSaveRewritesHistory() ? 'checked' : '' ?> type="checkbox"> <!-- checked="checked" -->
|
256 |
-
<label for="url_key_create_redirect"><?php echo $this->__('Create Permanent Redirect for old URL') ?></label>
|
257 |
</div>
|
258 |
<br/>
|
259 |
|
260 |
<div>
|
261 |
<button onclick="return showExample()">Example</button>
|
262 |
<span id="js-example"></span>
|
|
|
263 |
</div>
|
264 |
<br/>
|
265 |
<button id="apply" onclick="submitChanges('<?php echo $this->getSubmitUrl() ?>')"><?php echo $this->__('Apply') ?></button>
|
266 |
|
267 |
-
<script lang="Javascript">
|
268 |
|
269 |
function showExample() {
|
270 |
var pattern = serializePattern();
|
|
|
|
|
271 |
jQuery.ajax({
|
272 |
method: 'get',
|
273 |
url: '<?php echo $this->getExampleUrl() ?>',
|
@@ -275,86 +56,36 @@ p.inputTags-error:after {
|
|
275 |
pattern: pattern
|
276 |
}
|
277 |
}).success(function(data){
|
|
|
278 |
if(typeof data !== 'undefined' && data.isSuccess) {
|
279 |
jQuery('#js-example').text(data.exampleUrl);
|
280 |
}
|
281 |
});
|
282 |
return false;
|
283 |
-
}
|
284 |
-
|
285 |
-
jQuery.fn.textWidth = function(){
|
286 |
-
var html_org = jQuery(this).val();
|
287 |
-
var html_calc = '<span id="temp-span">' + html_org + '</span>';
|
288 |
-
jQuery('body').append(html_calc);
|
289 |
-
var width = jQuery('span#temp-span').width();
|
290 |
-
jQuery('span#temp-span').remove();
|
291 |
-
return width + (jQuery(this).val().length)*1.33;
|
292 |
-
};
|
293 |
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
};
|
299 |
|
300 |
-
jQuery.
|
301 |
-
jQuery(
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
|
|
307 |
}
|
308 |
});
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
// this.style.width = 10 + 'px';
|
316 |
-
// this.value = '';
|
317 |
-
// });
|
318 |
-
|
319 |
-
jQuery('.js-pattern').sortable({
|
320 |
-
connectWith: '.js-tag-cloud',
|
321 |
-
update: function(event, ui) {
|
322 |
-
jQuery(this).validatePattern();
|
323 |
-
}
|
324 |
-
});
|
325 |
-
jQuery('.js-tag-cloud').sortable({
|
326 |
-
connectWith: '.js-pattern'
|
327 |
-
});
|
328 |
-
|
329 |
-
jQuery('.js-pattern').click(function(e){
|
330 |
-
var clickedX = e.clientX;
|
331 |
-
var element = jQuery(this).children().closestToOffset({left: clickedX, top: e.clientY});
|
332 |
-
|
333 |
-
var elPositionX = element[0].offsetLeft;
|
334 |
-
if(clickedX < elPositionX) {
|
335 |
-
if(!jQuery(element).hasClass('inputTags-field') && !jQuery(element).prev().hasClass('inputTags-field')) {
|
336 |
-
jQuery('<input type=text value="" class="inputTags-field ui-sortable-handle"/>').insertBefore(element).adjustSize().focus();
|
337 |
-
} else {
|
338 |
-
if(jQuery(element).hasClass('inputTags-field')) {
|
339 |
-
jQuery(element).focus();
|
340 |
-
} else {
|
341 |
-
jQuery(element).prev().focus();
|
342 |
-
}
|
343 |
-
}
|
344 |
-
} else {
|
345 |
-
if(!jQuery(element).hasClass('inputTags-field') && !jQuery(element).next().hasClass('inputTags-field')) {
|
346 |
-
jQuery('<input type=text value="" class="inputTags-field ui-sortable-handle"/>').insertAfter(element).adjustSize().focus();
|
347 |
-
} else {
|
348 |
-
if(jQuery(element).hasClass('inputTags-field')) {
|
349 |
-
jQuery(element).focus();
|
350 |
-
} else {
|
351 |
-
jQuery(element).next().focus();
|
352 |
-
}
|
353 |
-
}
|
354 |
-
|
355 |
-
}
|
356 |
-
});
|
357 |
-
jQuery(document).ready(function(){
|
358 |
jQuery('.inputTags-field').adjustSize();
|
359 |
});
|
360 |
</script>
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
<div class="js-tag-cloud inputTags-list">
|
25 |
<?php echo $this->getAttributesCloudHtml() ?>
|
31 |
|
32 |
<div>
|
33 |
<input id="url_key_create_redirect" name="url_key_create_redirect" <?php echo $this->getSaveRewritesHistory() ? 'checked' : '' ?> type="checkbox"> <!-- checked="checked" -->
|
34 |
+
<label for="url_key_create_redirect"><?php echo $this->__('Create Permanent Redirect (301) for old URL') ?></label>
|
35 |
</div>
|
36 |
<br/>
|
37 |
|
38 |
<div>
|
39 |
<button onclick="return showExample()">Example</button>
|
40 |
<span id="js-example"></span>
|
41 |
+
<span id="loading"><span>.</span><span>.</span><span>.</span><span>.</span><span>.</span></span>
|
42 |
</div>
|
43 |
<br/>
|
44 |
<button id="apply" onclick="submitChanges('<?php echo $this->getSubmitUrl() ?>')"><?php echo $this->__('Apply') ?></button>
|
45 |
|
46 |
+
<script lang="Javascript">
|
47 |
|
48 |
function showExample() {
|
49 |
var pattern = serializePattern();
|
50 |
+
jQuery('#loading').show();
|
51 |
+
jQuery('#js-example').html('');
|
52 |
jQuery.ajax({
|
53 |
method: 'get',
|
54 |
url: '<?php echo $this->getExampleUrl() ?>',
|
56 |
pattern: pattern
|
57 |
}
|
58 |
}).success(function(data){
|
59 |
+
jQuery('#loading').hide();
|
60 |
if(typeof data !== 'undefined' && data.isSuccess) {
|
61 |
jQuery('#js-example').text(data.exampleUrl);
|
62 |
}
|
63 |
});
|
64 |
return false;
|
65 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
submitChanges = function(url) {
|
68 |
+
patternParam = serializePattern();
|
69 |
+
var saveRewrite = document.getElementById('url_key_create_redirect').checked == true ? 1 : 0;
|
70 |
+
location.href = url + '?pattern=' + encodeURIComponent(patternParam) + '&url_key_create_redirect=' + saveRewrite ;
|
71 |
+
};
|
72 |
|
73 |
+
jQuery(document).ready(function(){
|
74 |
+
jQuery('.js-pattern').sortable({
|
75 |
+
connectWith: '.js-tag-cloud',
|
76 |
+
start: function(e, ui ){
|
77 |
+
ui.placeholder.width(ui.helper.width()+34);
|
78 |
+
},
|
79 |
+
update: function(event, ui) {
|
80 |
+
jQuery(this).validatePattern();
|
81 |
}
|
82 |
});
|
83 |
+
jQuery('.js-tag-cloud').sortable({
|
84 |
+
connectWith: '.js-pattern',
|
85 |
+
start: function(e, ui ){
|
86 |
+
ui.placeholder.width(ui.helper.width()+34);
|
87 |
+
},
|
88 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
jQuery('.inputTags-field').adjustSize();
|
90 |
});
|
91 |
</script>
|
app/design/adminhtml/default/default/template/mklauza/customproducturls/system/settings.phtml
CHANGED
@@ -20,244 +20,26 @@
|
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
?>
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
<
|
27 |
-
<
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
html,
|
37 |
-
body {
|
38 |
-
width: 100%;
|
39 |
-
height: 100%;
|
40 |
-
margin: 0;
|
41 |
-
font-family: 'Ubuntu Condensed', sans-serif;
|
42 |
-
background-color: #dddddd;
|
43 |
-
}
|
44 |
-
h1 {
|
45 |
-
text-align: center;
|
46 |
-
margin-bottom: 32px;
|
47 |
-
}
|
48 |
-
div.container {
|
49 |
-
display: block;
|
50 |
-
width: 50%;
|
51 |
-
margin: 32px auto;
|
52 |
-
padding: 16px 32px;
|
53 |
-
background-color: #ffffff;
|
54 |
-
box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
|
55 |
-
}
|
56 |
-
div.inputTags-list {
|
57 |
-
display: inline-block;
|
58 |
-
width: 100%;
|
59 |
-
padding: 6px;
|
60 |
-
margin: 0 0 20px 0;
|
61 |
-
border: 1px solid rgba(25, 188, 156, 0.35);
|
62 |
-
background-color: #f9f9f9;
|
63 |
-
box-shadow: 1px 2px 2px rgba(221, 221, 221, 0.2);
|
64 |
-
border-radius: 4px;
|
65 |
-
}
|
66 |
-
div.inputTags-list span.inputTags-item {
|
67 |
-
position: relative;
|
68 |
-
display: inline-block;
|
69 |
-
margin: 2px;
|
70 |
-
padding: 3px 22px 4px 8px;
|
71 |
-
border-radius: 3px;
|
72 |
-
background-color: #19bc9c;
|
73 |
-
text-align: center;
|
74 |
-
color: #ffffff;
|
75 |
-
opacity: 1;
|
76 |
-
white-space: nowrap;
|
77 |
-
}
|
78 |
-
|
79 |
-
div.inputTags-list.tag-cloud span.inputTags-item {
|
80 |
-
background-color: #ed6502;
|
81 |
-
}
|
82 |
-
div.inputTags-list span.inputTags-item.blocked {
|
83 |
-
background-color: #ed6502;
|
84 |
-
}
|
85 |
-
|
86 |
-
div.inputTags-list span.inputTags-item.is-edit {
|
87 |
-
display: none;
|
88 |
-
}
|
89 |
-
div.inputTags-list span.inputTags-item.is-hidden {
|
90 |
-
display: none !important;
|
91 |
-
}
|
92 |
-
div.inputTags-list span.inputTags-item.is-exists {
|
93 |
-
background-color: rgba(231, 76, 60, 0.7);
|
94 |
-
}
|
95 |
-
div.inputTags-list span.inputTags-item span.value {
|
96 |
-
cursor: default;
|
97 |
-
}
|
98 |
-
div.inputTags-list span.inputTags-item i {
|
99 |
-
position: absolute;
|
100 |
-
top: 50%;
|
101 |
-
right: 6px;
|
102 |
-
font-size: 20px;
|
103 |
-
cursor: pointer;
|
104 |
-
z-index: 10;
|
105 |
-
font-weight: 400;
|
106 |
-
transition: color 0.2s;
|
107 |
-
font-family: sans-serif;
|
108 |
-
transform: translateY(-50%);
|
109 |
-
}
|
110 |
-
div.inputTags-list span.inputTags-item i:hover {
|
111 |
-
color: #e74c3c;
|
112 |
-
}
|
113 |
-
div.inputTags-list input.inputTags-field {
|
114 |
-
border: none;
|
115 |
-
width: auto;
|
116 |
-
white-space: nowrap;
|
117 |
-
margin-left: 4px;
|
118 |
-
background-color: transparent;
|
119 |
-
}
|
120 |
-
div.inputTags-list input.inputTags-field:focus,
|
121 |
-
div.inputTags-list input.inputTags-field:active {
|
122 |
-
outline: none;
|
123 |
-
}
|
124 |
-
div.inputTags-list input.inputTags-field.is-edit {
|
125 |
-
margin: 0 2px;
|
126 |
-
padding: 4px 8px 3px 8px;
|
127 |
-
border: 1px dashed #c4c4c4;
|
128 |
-
border-radius: 4px;
|
129 |
-
}
|
130 |
-
div.inputTags-list ul.inputTags-autocomplete-list {
|
131 |
-
position: absolute;
|
132 |
-
max-height: 192px;
|
133 |
-
margin: 0;
|
134 |
-
padding: 0;
|
135 |
-
list-style-type: none;
|
136 |
-
background-color: #ffffff;
|
137 |
-
border: 1px solid #dddddd;
|
138 |
-
border-radius: 4px;
|
139 |
-
transform: scaleY(0);
|
140 |
-
transform-origin: 50% 0;
|
141 |
-
transition-duration: 0.2s;
|
142 |
-
overflow-y: auto;
|
143 |
-
z-index: 100;
|
144 |
-
opacity: 0;
|
145 |
-
}
|
146 |
-
div.inputTags-list ul.inputTags-autocomplete-list.is-active {
|
147 |
-
opacity: 1;
|
148 |
-
transform: scaleY(1);
|
149 |
-
}
|
150 |
-
div.inputTags-list ul.inputTags-autocomplete-list li {
|
151 |
-
height: 32px;
|
152 |
-
line-height: 32px;
|
153 |
-
padding: 0 16px;
|
154 |
-
transition-duration: 0.3s;
|
155 |
-
cursor: pointer;
|
156 |
-
border-bottom: 1px solid #dddddd;
|
157 |
-
transition-duration: 0.2s;
|
158 |
-
}
|
159 |
-
div.inputTags-list ul.inputTags-autocomplete-list li:last-child {
|
160 |
-
border: none;
|
161 |
-
}
|
162 |
-
div.inputTags-list ul.inputTags-autocomplete-list li:hover {
|
163 |
-
background-color: #19bc9c;
|
164 |
-
color: #ffffff;
|
165 |
-
}
|
166 |
-
div.inputTags-list ul.inputTags-autocomplete-list li.is-disabled {
|
167 |
-
cursor: default;
|
168 |
-
background-color: #f7f7f7;
|
169 |
-
color: initial;
|
170 |
-
}
|
171 |
-
p.inputTags-error {
|
172 |
-
position: relative;
|
173 |
-
margin: 0;
|
174 |
-
padding: 0.5em 1em;
|
175 |
-
color: #ffffff;
|
176 |
-
background-color: rgba(231, 76, 60, 0.7);
|
177 |
-
border-radius: 4px;
|
178 |
-
cursor: pointer;
|
179 |
-
}
|
180 |
-
p.inputTags-error:first-of-type {
|
181 |
-
margin-top: 8px;
|
182 |
-
}
|
183 |
-
p.inputTags-error:after {
|
184 |
-
position: absolute;
|
185 |
-
content: "\000D7";
|
186 |
-
top: 50%;
|
187 |
-
right: 0.5em;
|
188 |
-
transform: translateY(-50%);
|
189 |
-
font-size: 28px;
|
190 |
-
}
|
191 |
-
</style>
|
192 |
-
|
193 |
-
<script lang="Javascript">
|
194 |
-
(function($) {
|
195 |
-
$.fn.closestToOffset = function(offset) {
|
196 |
-
var el = null, elOffset, x = offset.left, y = offset.top, distance, dx, dy, minDistance;
|
197 |
-
this.each(function() {
|
198 |
-
elOffset = $(this).offset();
|
199 |
-
|
200 |
-
if (
|
201 |
-
(x >= elOffset.left) && (x <= elOffset.right) &&
|
202 |
-
(y >= elOffset.top) && (y <= elOffset.bottom)
|
203 |
-
) {
|
204 |
-
el = $(this);
|
205 |
-
return false;
|
206 |
-
}
|
207 |
-
|
208 |
-
var offsets = [[elOffset.left, elOffset.top], [elOffset.right, elOffset.top], [elOffset.left, elOffset.bottom], [elOffset.right, elOffset.bottom]];
|
209 |
-
for (off in offsets) {
|
210 |
-
dx = offsets[off][0] - x;
|
211 |
-
dy = offsets[off][1] - y;
|
212 |
-
distance = Math.sqrt((dx*dx) + (dy*dy));
|
213 |
-
if (minDistance === undefined || distance < minDistance) {
|
214 |
-
minDistance = distance;
|
215 |
-
el = $(this);
|
216 |
-
}
|
217 |
-
}
|
218 |
-
});
|
219 |
-
return el;
|
220 |
-
}
|
221 |
-
})(jQuery);
|
222 |
-
</script>
|
223 |
-
|
224 |
-
<script lang="Javascript">
|
225 |
-
|
226 |
-
serializePattern = function() {
|
227 |
-
var patternParam = '';
|
228 |
-
jQuery('.js-pattern').children().each(function(){
|
229 |
-
if(jQuery(this).hasClass('inputTags-item')) {
|
230 |
-
patternParam += '{'+jQuery(this).data('value')+'}';
|
231 |
-
} else if(jQuery(this).hasClass('inputTags-field')) {
|
232 |
-
patternParam += jQuery(this).val();
|
233 |
-
}
|
234 |
-
});
|
235 |
-
return patternParam;
|
236 |
-
};
|
237 |
-
|
238 |
-
submitChanges = function() {
|
239 |
-
jQuery('#<?php echo $this->getElement()->getHtmlId() ?>').val(serializePattern());
|
240 |
-
};
|
241 |
-
|
242 |
-
</script>
|
243 |
-
|
244 |
-
<div class="js-tag-cloud inputTags-list">
|
245 |
-
<?php echo $this->getAttributesCloudHtml() ?>
|
246 |
-
</div>
|
247 |
-
<br/>
|
248 |
-
<div class="js-pattern inputTags-list">
|
249 |
-
<?php echo $this->getPatternHtml() ?>
|
250 |
-
</div>
|
251 |
-
|
252 |
-
<?php echo $this->getElement()->getElementHtml() ?>
|
253 |
-
|
254 |
-
<button onclick="return showExample()">Example</button>
|
255 |
-
<span id="js-example"></span>
|
256 |
|
257 |
-
<script lang="Javascript">
|
258 |
|
259 |
function showExample() {
|
260 |
var pattern = serializePattern();
|
|
|
|
|
261 |
jQuery.ajax({
|
262 |
method: 'get',
|
263 |
url: '<?php echo $this->getExampleUrl() ?>',
|
@@ -265,89 +47,46 @@ p.inputTags-error:after {
|
|
265 |
pattern: pattern
|
266 |
}
|
267 |
}).success(function(data){
|
|
|
268 |
if(typeof data !== 'undefined' && data.isSuccess) {
|
269 |
jQuery('#js-example').text(data.exampleUrl);
|
270 |
}
|
271 |
});
|
272 |
return false;
|
273 |
-
}
|
274 |
-
|
275 |
-
|
276 |
-
var html_org = jQuery(this).val();
|
277 |
-
var html_calc = '<span id="temp-span">' + html_org + '</span>';
|
278 |
-
jQuery('body').append(html_calc);
|
279 |
-
var width = jQuery('span#temp-span').width();
|
280 |
-
jQuery('span#temp-span').remove();
|
281 |
-
return width + (jQuery(this).val().length)*1.33;
|
282 |
-
};
|
283 |
-
|
284 |
-
jQuery.fn.adjustSize = function() {
|
285 |
-
return jQuery(this).each(function(){
|
286 |
-
jQuery(this).css('width', jQuery(this).textWidth()+5 + 'px' );
|
287 |
-
});
|
288 |
-
};
|
289 |
-
|
290 |
-
jQuery.fn.validatePattern = function() {
|
291 |
-
jQuery(this).children().each(function(){
|
292 |
-
if(jQuery(this).hasClass('inputTags-field') && jQuery(this).next().hasClass('inputTags-field')) {
|
293 |
-
if( jQuery(this).next().val() !== '') {
|
294 |
-
jQuery(this).val( jQuery(this).val() + '-' + jQuery(this).next().val()).adjustSize();
|
295 |
-
}
|
296 |
-
jQuery(this).next().remove();
|
297 |
-
}
|
298 |
-
});
|
299 |
};
|
300 |
|
301 |
-
jQuery(
|
302 |
-
|
303 |
-
});
|
304 |
-
|
305 |
-
jQuery('.js-pattern').sortable({
|
306 |
-
connectWith: '.js-tag-cloud',
|
307 |
-
update: function(event, ui) {
|
308 |
-
jQuery(this).validatePattern();
|
309 |
-
submitChanges();
|
310 |
-
}
|
311 |
-
});
|
312 |
-
jQuery('body').on('change', '.js-pattern', function(){
|
313 |
-
submitChanges();
|
314 |
});
|
315 |
-
|
316 |
-
jQuery('.js-tag-cloud').sortable({
|
317 |
-
connectWith: '.js-pattern'
|
318 |
-
});
|
319 |
-
|
320 |
-
jQuery('.js-pattern').click(function(e){
|
321 |
-
var clickedX = e.clientX;
|
322 |
-
var element = jQuery(this).children().closestToOffset({left: clickedX, top: e.clientY});
|
323 |
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
jQuery('<input type=text value="" class="inputTags-field ui-sortable-handle"/>').insertBefore(element).adjustSize().focus();
|
328 |
-
} else {
|
329 |
-
if(jQuery(element).hasClass('inputTags-field')) {
|
330 |
-
jQuery(element).focus();
|
331 |
-
} else {
|
332 |
-
jQuery(element).prev().focus();
|
333 |
-
}
|
334 |
-
}
|
335 |
-
} else {
|
336 |
-
if(!jQuery(element).hasClass('inputTags-field') && !jQuery(element).next().hasClass('inputTags-field')) {
|
337 |
-
jQuery('<input type=text value="" class="inputTags-field ui-sortable-handle"/>').insertAfter(element).adjustSize().focus();
|
338 |
-
} else {
|
339 |
-
if(jQuery(element).hasClass('inputTags-field')) {
|
340 |
-
jQuery(element).focus();
|
341 |
-
} else {
|
342 |
-
jQuery(element).next().focus();
|
343 |
-
}
|
344 |
-
}
|
345 |
-
|
346 |
-
}
|
347 |
-
});
|
348 |
|
349 |
jQuery(document).ready(function(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
jQuery('.inputTags-field').adjustSize();
|
|
|
351 |
});
|
352 |
|
353 |
</script>
|
20 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
*/
|
22 |
?>
|
23 |
+
<div class="js-tag-cloud inputTags-list">
|
24 |
+
<?php echo $this->getAttributesCloudHtml() ?>
|
25 |
+
</div>
|
26 |
+
<br/>
|
27 |
+
<div class="js-pattern inputTags-list">
|
28 |
+
<?php echo $this->getPatternHtml() ?>
|
29 |
+
</div>
|
30 |
+
|
31 |
+
<?php echo $this->getElement()->getElementHtml() ?>
|
32 |
+
|
33 |
+
<button onclick="return showExample()">Example</button>
|
34 |
+
<span id="js-example"></span>
|
35 |
+
<span id="loading"><span>.</span><span>.</span><span>.</span><span>.</span><span>.</span></span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
<script lang="Javascript">
|
38 |
|
39 |
function showExample() {
|
40 |
var pattern = serializePattern();
|
41 |
+
jQuery('#loading').show();
|
42 |
+
jQuery('#js-example').html('');
|
43 |
jQuery.ajax({
|
44 |
method: 'get',
|
45 |
url: '<?php echo $this->getExampleUrl() ?>',
|
47 |
pattern: pattern
|
48 |
}
|
49 |
}).success(function(data){
|
50 |
+
jQuery('#loading').hide();
|
51 |
if(typeof data !== 'undefined' && data.isSuccess) {
|
52 |
jQuery('#js-example').text(data.exampleUrl);
|
53 |
}
|
54 |
});
|
55 |
return false;
|
56 |
+
}
|
57 |
+
prepareSave = function() {
|
58 |
+
jQuery('#<?php echo $this->getElement()->getHtmlId() ?>').val(serializePattern());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
};
|
60 |
|
61 |
+
jQuery(document).on('change', '.js-pattern', function(){
|
62 |
+
prepareSave();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
+
jQuery(document).on('change', '#mklauza_customproducturls_general_pattern_inherit', function() {
|
66 |
+
this.checked ? disableFields() : enableFileds();
|
67 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
jQuery(document).ready(function(){
|
70 |
+
|
71 |
+
jQuery('.js-pattern').sortable({
|
72 |
+
connectWith: '.js-tag-cloud',
|
73 |
+
update: function(event, ui) {
|
74 |
+
jQuery(this).validatePattern();
|
75 |
+
prepareSave();
|
76 |
+
},
|
77 |
+
start: function(e, ui ){
|
78 |
+
ui.placeholder.width(ui.helper.width()+34);
|
79 |
+
},
|
80 |
+
});
|
81 |
+
|
82 |
+
jQuery('.js-tag-cloud').sortable({
|
83 |
+
connectWith: '.js-pattern',
|
84 |
+
start: function(e, ui ){
|
85 |
+
ui.placeholder.width(ui.helper.width()+34);
|
86 |
+
},
|
87 |
+
});
|
88 |
jQuery('.inputTags-field').adjustSize();
|
89 |
+
jQuery('#mklauza_customproducturls_general_pattern_inherit').change();
|
90 |
});
|
91 |
|
92 |
</script>
|
package.xml
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>2f0ed0fddbc299a929e59604a51b5159</name>
|
4 |
-
<version>1.0.
|
5 |
-
<stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>Extension allowing to mass change product url key according to template consisting of product attributes.</description>
|
11 |
<notes>notes</notes>
|
12 |
<authors><author><name>Marcin Klauza</name><user>marcin</user><email>marcinklauza@gmail.com</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir><dir name="Mklauza"><dir name="CustomProductUrls"><dir name="Block"><dir name="Adminhtml"><dir name="Form"><file name="Abstract.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>2f0ed0fddbc299a929e59604a51b5159</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
+
<stability>beta</stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
10 |
<description>Extension allowing to mass change product url key according to template consisting of product attributes.</description>
|
11 |
<notes>notes</notes>
|
12 |
<authors><author><name>Marcin Klauza</name><user>marcin</user><email>marcinklauza@gmail.com</email></author></authors>
|
13 |
+
<date>2016-02-26</date>
|
14 |
+
<time>20:51:47</time>
|
15 |
+
<contents><target name="magecommunity"><dir><dir name="Mklauza"><dir name="CustomProductUrls"><dir name="Block"><dir name="Adminhtml"><dir name="Form"><file name="Abstract.php" hash="46b8e3c1473c8d2b340d488dcf42902a"/><file name="Massaction.php" hash="32bb6193eea4b61a47ac589879b6a231"/><file name="Settings.php" hash="daeaa0ed5176e34677169b6f73f26f3e"/></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Pattern.php" hash="34dc42258f8d40b3d6adb64371e9d1f6"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="2c4bbf6096320edab9f21943277299e3"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="bdafa3c0c15b7b95be015af5cd801266"/></dir><dir name="Catalog"><dir name="Product"><file name="Url.php" hash="94a90ca37095d7b2cda703336474befe"/></dir><dir name="Resource"><dir name="Product"><file name="Action.php" hash="ba5c44db2c31aa1d2be5368394e0d66a"/></dir></dir></dir><file name="Pattern.php" hash="84e7431997465054775a6d982e772a85"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Action"><file name="ProductUrlsMassActionController.php" hash="e65f8a587854e95f02e862666562661c"/></dir></dir></dir><file name="ProductUrlsController.php" hash="5fcb9eb4ab89f9c611837e37058e46fd"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="dad9c0dd1088595d6da2474e69ff7ce6"/><file name="config.xml" hash="16cc3389cbb18191a4f3e9a2e7d32a83"/><file name="system.xml" hash="bd5402bc4b30168d4aa67a91b94b11d3"/></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="mklauza"><file name="product_urls.xml" hash="972b7551a3fbcb7b8bc87aff5732c52c"/></dir></dir><dir name="template"><dir name="mklauza"><dir name="customproducturls"><file name="massaction.phtml" hash="03afd8fc8ed7129abef818c34bac6503"/><dir name="system"><file name="settings.phtml" hash="d2c9195d497cd76a4b0cc541b1165fa0"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Mklauza_CustomProductUrls.xml" hash="0f6d8d6a5dd2261fed9f49e853f68adf"/></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|