Skip to content

Commit f5ec47f

Browse files
committed
[FEATURE]
- Added robots configuration to cms pages - Added robots configuration to category pages - Added robots configuration to product pages - Added configuration to set robots on paginated category pages to noindex, follow in catalog < search engine optimizations - Extended robots in backend configuration with INDEX,FOLLOW,NOARCHIVE, INDEX,NOFOLLOW,NOARCHIVE and NOINDEX,NOFOLLOW,NOARCHIVE - Added robots configuration for contacts in general > web - Added robots configuration for search and advanced search in general > web - Added robots configuration for customer login form and resetpassword in general > web - Added robots configuration for cart, checkout, failure page and success page in general > web - Added robots configuration to compare list in general > web - Added robots configuration to wish list in general > web - Added robots configuration to send friend page in general > web - Added robots configuration to review page and list in general > web - Added robots configuration to tag page and list in general > web - Added robots configuration to rss list page in general > web - Added robots configuration to orders and refurns page in general > web
1 parent 6ab0b92 commit f5ec47f

File tree

55 files changed

+739
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+739
-228
lines changed

app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Meta.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ protected function _prepareForm()
7373
'disabled' => $isElementDisabled
7474
));
7575

76+
$fieldset->addField('meta_robots', 'select', array(
77+
'name' => 'meta_robots',
78+
'label' => Mage::helper('cms')->__('Robots'),
79+
'title' => Mage::helper('cms')->__('Meta Robots'),
80+
'options' => $model->getAvailableRobots(),
81+
'disabled' => $isElementDisabled
82+
));
83+
7684
Mage::dispatchEvent('adminhtml_cms_page_edit_tab_meta_prepare_form', array('form' => $form));
7785

7886
$form->setValues($model->getData());

app/code/core/Mage/Adminhtml/Model/System/Config/Source/Design/Robots.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function toOptionArray()
3434
array('value'=>'NOINDEX,FOLLOW', 'label'=>'NOINDEX, FOLLOW'),
3535
array('value'=>'INDEX,NOFOLLOW', 'label'=>'INDEX, NOFOLLOW'),
3636
array('value'=>'NOINDEX,NOFOLLOW', 'label'=>'NOINDEX, NOFOLLOW'),
37+
array('value'=>'INDEX,FOLLOW,NOARCHIVE', 'label'=>'INDEX, FOLLOW, NOARCHIVE'),
38+
array('value'=>'INDEX,NOINDEX,NOARCHIVE', 'label'=>'INDEX, NOINDEX, NOARCHIVE'),
39+
array('value'=>'NOINDEX,NOFOLLOW, NOARCHIVE', 'label'=>'NOINDEX, NOFOLLOW, NOARCHIVE'),
3740
);
3841
}
3942
}

app/code/core/Mage/Catalog/Block/Category/View.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ protected function _prepareLayout()
5454
if ($keywords = $category->getMetaKeywords()) {
5555
$headBlock->setKeywords($keywords);
5656
}
57+
if ($robots = $category->getMetaRobots()) {
58+
if(Mage::helper('catalog/category')->canUseNoindexFollow() && Mage::helper('catalog/category')->isNotFirstCategoryPage()) {
59+
$headBlock->setRobots(Mage::getSingleton('catalog/category_attribute_source_robots')->getOptionLabel(3));
60+
} else {
61+
$headBlock->setRobots(Mage::getSingleton('catalog/category_attribute_source_robots')->getOptionLabel($robots));
62+
}
63+
}
5764
if ($this->helper('catalog/category')->canUseCanonicalTag()) {
5865
$headBlock->addLinkRel('canonical', $category->getUrl());
5966
}

app/code/core/Mage/Catalog/Block/Product/View.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ protected function _prepareLayout()
7474
} else {
7575
$headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255));
7676
}
77+
$robots = $product->getMetaRobots();
78+
if ($robots) {
79+
$headBlock->setRobots(Mage::getSingleton('catalog/product_attribute_source_robots')->getOptionLabel($robots));
80+
} else {
81+
$headBlock->setRobots(Mage::getStoreConfig('design/head/default_robots'));
82+
}
7783
if ($this->helper('catalog/product')->canUseCanonicalTag()) {
7884
$params = array('_ignore_category' => true);
7985
$headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params));

app/code/core/Mage/Catalog/Helper/Category.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Mage_Catalog_Helper_Category extends Mage_Core_Helper_Abstract
3535
{
3636
const XML_PATH_CATEGORY_URL_SUFFIX = 'catalog/seo/category_url_suffix';
3737
const XML_PATH_USE_CATEGORY_CANONICAL_TAG = 'catalog/seo/category_canonical_tag';
38+
const XML_PATH_CHANGE_CATEGORY_PAGES_ROBOTS_= 'catalog/seo/category_pages_robots';
3839
const XML_PATH_CATEGORY_ROOT_ID = 'catalog/category/root_id';
3940

4041
/**
@@ -183,4 +184,29 @@ public function canUseCanonicalTag($store = null)
183184
{
184185
return Mage::getStoreConfig(self::XML_PATH_USE_CATEGORY_CANONICAL_TAG, $store);
185186
}
187+
188+
/**
189+
* Check if Robots NOINDEX,FOLLOW can be used for category pages
190+
*
191+
* @param null|string|bool|int|Mage_Core_Model_Store $store
192+
* @return bool
193+
*/
194+
public function canUseNoindexFollow($store = null)
195+
{
196+
return Mage::getStoreConfig(self::XML_PATH_CHANGE_CATEGORY_PAGES_ROBOTS_, $store);
197+
}
198+
199+
200+
/**
201+
* Check if current category is first page
202+
*
203+
* @return boolean
204+
*/
205+
public function isNotFirstCategoryPage() {
206+
$url = Mage::helper('core/url')->getCurrentUrl();
207+
$parsedUrl = parse_url($url);
208+
if(isset($parsedUrl['query']) && (preg_match("/p=/i", $parsedUrl['query'])) && (!preg_match("/p=1/i", $parsedUrl['query']))){
209+
return true;
210+
}
211+
}
186212
}

app/code/core/Mage/Catalog/Model/Api2/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function _isAttributeVisible(Mage_Catalog_Model_Resource_Eav_Attribute
8181
} else {
8282
$systemAttributesForNonAdmin = array(
8383
'sku', 'name', 'short_description', 'description', 'tier_price', 'meta_title', 'meta_description',
84-
'meta_keyword',
84+
'meta_keyword', 'meta_robot'
8585
);
8686
if ($attribute->getIsUserDefined()) {
8787
$isAttributeVisible = $attribute->getIsVisibleOnFront();

app/code/core/Mage/Catalog/Model/Category.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
*
6969
* @method string getMetaDescription()
7070
* @method string getMetaKeywords()
71+
* @method int getMetaRobots()
7172
* @method string getMetaTitle()
7273
* @method int getMovedCategoryId()
7374
*
@@ -103,6 +104,18 @@ class Mage_Catalog_Model_Category extends Mage_Catalog_Model_Abstract
103104
const DM_MIXED = 'PRODUCTS_AND_PAGE';
104105
const TREE_ROOT_ID = 1;
105106

107+
/**
108+
* Category robots
109+
*/
110+
const META_ROBOTS_INDEX_FOLLOW = 1;
111+
const META_ROBOTS_INDEX_NOFOLLOW = 2;
112+
const META_ROBOTS_NOINDEX_FOLLOW = 3;
113+
const META_ROBOTS_NOINDEX_NOFOLLOW = 4;
114+
const META_ROBOTS_INDEX_FOLLOW_NOARCHIVE = 5;
115+
const META_ROBOTS_INDEX_NOFOLLOW_NOARCHIVE = 6;
116+
const META_ROBOTS_NOINDEX_NOFOLLOW_NOARCHIVE = 7;
117+
118+
106119
const CACHE_TAG = 'catalog_category';
107120

108121
/**
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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_Catalog
23+
* @copyright Copyright (c) 2006-2020 Magento, 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+
* Catalog category robots attribute source
29+
*
30+
* @category Mage
31+
* @package Mage_Catalog
32+
* @author Magento Core Team <core@magentocommerce.com>
33+
*/
34+
class Mage_Catalog_Model_Category_Attribute_Source_Robots extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
35+
{
36+
/**
37+
* @return array
38+
*/
39+
public function getAllOptions()
40+
{
41+
return array(
42+
Mage_Catalog_Model_Category::META_ROBOTS_INDEX_FOLLOW =>
43+
array(
44+
'value' => Mage_Catalog_Model_Category::META_ROBOTS_INDEX_FOLLOW,
45+
'label' => Mage::helper('cms')->__('INDEX,FOLLOW')
46+
),
47+
Mage_Catalog_Model_Category::META_ROBOTS_INDEX_NOFOLLOW =>
48+
array(
49+
'value' => Mage_Catalog_Model_Category::META_ROBOTS_INDEX_NOFOLLOW,
50+
'label' => Mage::helper('cms')->__('INDEX,NOFOLLOW')
51+
),
52+
Mage_Catalog_Model_Category::META_ROBOTS_NOINDEX_FOLLOW =>
53+
array(
54+
'value' => Mage_Catalog_Model_Category::META_ROBOTS_NOINDEX_FOLLOW,
55+
'label' => Mage::helper('cms')->__('NOINDEX,FOLLOW')
56+
),
57+
Mage_Catalog_Model_Category::META_ROBOTS_NOINDEX_NOFOLLOW =>
58+
array(
59+
'value' => Mage_Catalog_Model_Category::META_ROBOTS_NOINDEX_NOFOLLOW,
60+
'label' => Mage::helper('cms')->__('NOINDEX,NOFOLLOW')
61+
),
62+
Mage_Catalog_Model_Category::META_ROBOTS_INDEX_FOLLOW_NOARCHIVE =>
63+
array(
64+
'value' => Mage_Catalog_Model_Category::META_ROBOTS_INDEX_FOLLOW_NOARCHIVE,
65+
'label' => Mage::helper('cms')->__('INDEX,FOLLOW,NOARCHIVE')
66+
),
67+
Mage_Catalog_Model_Category::META_ROBOTS_INDEX_NOFOLLOW_NOARCHIVE =>
68+
array(
69+
'value' => Mage_Catalog_Model_Category::META_ROBOTS_INDEX_NOFOLLOW_NOARCHIVE,
70+
'label' => Mage::helper('cms')->__('INDEX,NOFOLLOW,NOARCHIVE')
71+
),
72+
Mage_Catalog_Model_Category::META_ROBOTS_NOINDEX_NOFOLLOW_NOARCHIVE =>
73+
array(
74+
'value' => Mage_Catalog_Model_Category::META_ROBOTS_NOINDEX_NOFOLLOW_NOARCHIVE,
75+
'label' => Mage::helper('cms')->__('NOINDEX,NOFOLLOW,NOARCHIVE')
76+
),
77+
);
78+
}
79+
80+
/**
81+
* @param int $key
82+
* @return string
83+
*/
84+
public function getOptionLabel($key) {
85+
$options = $this->getAllOptions();
86+
87+
return $options[$key]['label'];
88+
}
89+
}

app/code/core/Mage/Catalog/Model/Product.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
* @method array getMediaGallery()
144144
* @method $this setMediaGallery(array $value)
145145
* @method string getMessage()
146+
* @method int getMetaRobot()
146147
* @method string getMetaDescription()
147148
* @method string getMetaKeyword()
148149
* @method string getMetaTitle()
@@ -277,6 +278,17 @@ class Mage_Catalog_Model_Product extends Mage_Catalog_Model_Abstract
277278
*/
278279
const ENTITY = 'catalog_product';
279280

281+
/**
282+
* Product robots
283+
*/
284+
const META_ROBOTS_INDEX_FOLLOW = 1;
285+
const META_ROBOTS_INDEX_NOFOLLOW = 2;
286+
const META_ROBOTS_NOINDEX_FOLLOW = 3;
287+
const META_ROBOTS_NOINDEX_NOFOLLOW = 4;
288+
const META_ROBOTS_INDEX_FOLLOW_NOARCHIVE = 5;
289+
const META_ROBOTS_INDEX_NOFOLLOW_NOARCHIVE = 6;
290+
const META_ROBOTS_NOINDEX_NOFOLLOW_NOARCHIVE = 7;
291+
280292
const CACHE_TAG = 'catalog_product';
281293
protected $_cacheTag = 'catalog_product';
282294
protected $_eventPrefix = 'catalog_product';

app/code/core/Mage/Catalog/Model/Product/Api.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class Mage_Catalog_Model_Product_Api extends Mage_Catalog_Model_Api_Resource
6363
'meta_title',
6464
'meta_keyword',
6565
'meta_description',
66+
'meta_robot',
6667
'custom_design',
6768
'custom_layout_update',
6869
'options_container',

0 commit comments

Comments
 (0)