Version Notes
Google Rich Snippets helps you highlight your products among search results of search engines by various types of rich snippets.
Download this release
Release Info
| Developer | Magebuzz |
| Extension | magebuzz_google_rich_snippets |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Version 0.1.0
- app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet.php +17 -0
- app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Edit.php +27 -0
- app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Edit/Form.php +25 -0
- app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Edit/Tab/Form.php +54 -0
- app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Edit/Tabs.php +30 -0
- app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Grid.php +109 -0
- app/code/local/Magebuzz/Snippet/Block/Breadcrumb.php +18 -0
- app/code/local/Magebuzz/Snippet/Block/Category.php +25 -0
- app/code/local/Magebuzz/Snippet/Block/Organization.php +16 -0
- app/code/local/Magebuzz/Snippet/Block/Product.php +29 -0
- app/code/local/Magebuzz/Snippet/Helper/Data.php +100 -0
- app/code/local/Magebuzz/Snippet/Model/Mysql4/Snippet.php +9 -0
- app/code/local/Magebuzz/Snippet/Model/Mysql4/Snippet/Collection.php +10 -0
- app/code/local/Magebuzz/Snippet/Model/Observer.php +10 -0
- app/code/local/Magebuzz/Snippet/Model/Snippet.php +10 -0
- app/code/local/Magebuzz/Snippet/Model/Status.php +37 -0
- app/code/local/Magebuzz/Snippet/controllers/Adminhtml/SnippetController.php +334 -0
- app/code/local/Magebuzz/Snippet/controllers/IndexController.php +13 -0
- app/code/local/Magebuzz/Snippet/etc/adminhtml.xml +58 -0
- app/code/local/Magebuzz/Snippet/etc/config.xml +133 -0
- app/code/local/Magebuzz/Snippet/etc/system.xml +250 -0
- app/code/local/Magebuzz/Snippet/sql/snippet_setup/mysql4-install-0.1.0.php +27 -0
- app/design/adminhtml/default/default/layout/snippet.xml +8 -0
- app/design/frontend/base/default/layout/snippet.xml +28 -0
- app/design/frontend/base/default/template/snippet/breadcrumbs.phtml +25 -0
- app/design/frontend/base/default/template/snippet/category.phtml +35 -0
- app/design/frontend/base/default/template/snippet/organization.phtml +32 -0
- app/design/frontend/base/default/template/snippet/product.phtml +46 -0
- app/etc/modules/Magebuzz_Snippet.xml +13 -0
- app/locale/en_US/Magebuzz_Snippet.csv +49 -0
- package.xml +18 -0
app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Adminhtml_Snippet extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
$this->_controller = 'adminhtml_snippet';
|
| 8 |
+
$this->_blockGroup = 'snippet';
|
| 9 |
+
$this->_headerText = Mage::helper('snippet')->__('All Category Reviews');
|
| 10 |
+
if (Mage::getModel('snippet/snippet')->getCollection()->getSize() <= 0) {
|
| 11 |
+
$this->_addButtonLabel = Mage::helper('snippet')->__('Generate');
|
| 12 |
+
} else {
|
| 13 |
+
$this->_addButtonLabel = Mage::helper('snippet')->__('Delete Current Data and Re-Generate');
|
| 14 |
+
}
|
| 15 |
+
parent::__construct();
|
| 16 |
+
}
|
| 17 |
+
}
|
app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Edit.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Adminhtml_Snippet_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
parent::__construct();
|
| 8 |
+
$this->_removeButton('delete');
|
| 9 |
+
|
| 10 |
+
$this->_objectId = 'id';
|
| 11 |
+
$this->_blockGroup = 'snippet';
|
| 12 |
+
$this->_controller = 'adminhtml_snippet';
|
| 13 |
+
|
| 14 |
+
$this->_updateButton('save', 'label', Mage::helper('snippet')->__('Save Item'));
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
public function getHeaderText()
|
| 18 |
+
{
|
| 19 |
+
if (Mage::registry('snippet_data')
|
| 20 |
+
&& Mage::registry('snippet_data')->getId()
|
| 21 |
+
) {
|
| 22 |
+
return Mage::helper('snippet')->__("Edit Category Id '%s'", $this->htmlEscape(Mage::registry('snippet_data')
|
| 23 |
+
->getCategoryId()));
|
| 24 |
+
}
|
| 25 |
+
return Mage::helper('snippet')->__('Add Item');
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Edit/Form.php
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Adminhtml_Snippet_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* prepare form's information for block
|
| 7 |
+
*
|
| 8 |
+
* @return Magebuzz_Snippet_Block_Adminhtml_Snippet_Edit_Form
|
| 9 |
+
*/
|
| 10 |
+
protected function _prepareForm()
|
| 11 |
+
{
|
| 12 |
+
$form = new Varien_Data_Form(array(
|
| 13 |
+
'id' => 'edit_form',
|
| 14 |
+
'action' => $this->getUrl('*/*/save', array(
|
| 15 |
+
'id' => $this->getRequest()->getParam('id'),
|
| 16 |
+
)),
|
| 17 |
+
'method' => 'post',
|
| 18 |
+
'enctype' => 'multipart/form-data'
|
| 19 |
+
));
|
| 20 |
+
|
| 21 |
+
$form->setUseContainer(true);
|
| 22 |
+
$this->setForm($form);
|
| 23 |
+
return parent::_prepareForm();
|
| 24 |
+
}
|
| 25 |
+
}
|
app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Edit/Tab/Form.php
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Adminhtml_Snippet_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* prepare tab form's information
|
| 7 |
+
*
|
| 8 |
+
* @return Magebuzz_Snippet_Block_Adminhtml_Snippet_Edit_Tab_Form
|
| 9 |
+
*/
|
| 10 |
+
protected function _prepareForm()
|
| 11 |
+
{
|
| 12 |
+
$form = new Varien_Data_Form();
|
| 13 |
+
$this->setForm($form);
|
| 14 |
+
|
| 15 |
+
if (Mage::getSingleton('adminhtml/session')->getSnippetData()) {
|
| 16 |
+
$data = Mage::getSingleton('adminhtml/session')->getSnippetData();
|
| 17 |
+
Mage::getSingleton('adminhtml/session')->setSnippetData(null);
|
| 18 |
+
} elseif (Mage::registry('snippet_data')) {
|
| 19 |
+
$data = Mage::registry('snippet_data')->getData();
|
| 20 |
+
}
|
| 21 |
+
$fieldset = $form->addFieldset('snippet_form', array(
|
| 22 |
+
'legend' => Mage::helper('snippet')->__('Category information')
|
| 23 |
+
));
|
| 24 |
+
|
| 25 |
+
$fieldset->addField('category_id', 'text', array(
|
| 26 |
+
'label' => Mage::helper('snippet')->__('Category'),
|
| 27 |
+
'class' => 'required-entry',
|
| 28 |
+
'disabled' => true,
|
| 29 |
+
'required' => true,
|
| 30 |
+
'name' => 'category_id',
|
| 31 |
+
));
|
| 32 |
+
|
| 33 |
+
$fieldset->addField('reviews_count', 'text', array(
|
| 34 |
+
'label' => Mage::helper('snippet')->__('Reviews Count'),
|
| 35 |
+
'required' => true,
|
| 36 |
+
'name' => 'reviews_count',
|
| 37 |
+
));
|
| 38 |
+
|
| 39 |
+
$fieldset->addField('rating', 'text', array(
|
| 40 |
+
'label' => Mage::helper('snippet')->__('Ratings'),
|
| 41 |
+
'required' => true,
|
| 42 |
+
'name' => 'rating',
|
| 43 |
+
));
|
| 44 |
+
|
| 45 |
+
$fieldset->addField('from_price', 'text', array(
|
| 46 |
+
'label' => Mage::helper('snippet')->__('Start Price'),
|
| 47 |
+
'required' => true,
|
| 48 |
+
'name' => 'from_price',
|
| 49 |
+
));
|
| 50 |
+
|
| 51 |
+
$form->setValues($data);
|
| 52 |
+
return parent::_prepareForm();
|
| 53 |
+
}
|
| 54 |
+
}
|
app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Edit/Tabs.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Adminhtml_Snippet_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
parent::__construct();
|
| 8 |
+
$this->setId('snippet_tabs');
|
| 9 |
+
$this->setDestElementId('edit_form');
|
| 10 |
+
$this->setTitle(Mage::helper('snippet')->__('Category Information'));
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* prepare before render block to html
|
| 15 |
+
*
|
| 16 |
+
* @return Magebuzz_Snippet_Block_Adminhtml_Snippet_Edit_Tabs
|
| 17 |
+
*/
|
| 18 |
+
protected function _beforeToHtml()
|
| 19 |
+
{
|
| 20 |
+
$this->addTab('form_section', array(
|
| 21 |
+
'label' => Mage::helper('snippet')->__('Category Information'),
|
| 22 |
+
'title' => Mage::helper('snippet')->__('Category Information'),
|
| 23 |
+
'content' => $this->getLayout()
|
| 24 |
+
->createBlock('snippet/adminhtml_snippet_edit_tab_form')
|
| 25 |
+
->toHtml(),
|
| 26 |
+
));
|
| 27 |
+
return parent::_beforeToHtml();
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
}
|
app/code/local/Magebuzz/Snippet/Block/Adminhtml/Snippet/Grid.php
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Adminhtml_Snippet_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
parent::__construct();
|
| 8 |
+
$this->setId('snippetGrid');
|
| 9 |
+
$this->setDefaultSort('category_id');
|
| 10 |
+
$this->setDefaultDir('ASC');
|
| 11 |
+
$this->setSaveParametersInSession(true);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* prepare collection for block to display
|
| 16 |
+
*
|
| 17 |
+
* @return Magebuzz_Snippet_Block_Adminhtml_Snippet_Grid
|
| 18 |
+
*/
|
| 19 |
+
protected function _prepareCollection()
|
| 20 |
+
{
|
| 21 |
+
$collection = Mage::getModel('snippet/snippet')->getCollection();
|
| 22 |
+
$collection->getSelect()->join(Mage::getConfig()->getTablePrefix() . 'catalog_category_flat_store_1',
|
| 23 |
+
'category_id= ' . Mage::getConfig()->getTablePrefix() . 'catalog_category_flat_store_1.entity_id',
|
| 24 |
+
array('name'));
|
| 25 |
+
$this->setCollection($collection);
|
| 26 |
+
return parent::_prepareCollection();
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* prepare columns for this grid
|
| 31 |
+
*
|
| 32 |
+
* @return Magebuzz_Snippet_Block_Adminhtml_Snippet_Grid
|
| 33 |
+
*/
|
| 34 |
+
protected function _prepareColumns()
|
| 35 |
+
{
|
| 36 |
+
$this->addColumn('category_id', array(
|
| 37 |
+
'header' => Mage::helper('snippet')->__('Category ID'),
|
| 38 |
+
'align' => 'right',
|
| 39 |
+
'index' => 'category_id',
|
| 40 |
+
));
|
| 41 |
+
|
| 42 |
+
$this->addColumn('name', array(
|
| 43 |
+
'header' => Mage::helper('snippet')->__('Category Name'),
|
| 44 |
+
'align' => 'left',
|
| 45 |
+
'index' => 'name',
|
| 46 |
+
));
|
| 47 |
+
|
| 48 |
+
$this->addColumn('reviews_count', array(
|
| 49 |
+
'header' => Mage::helper('snippet')->__('Reviews Count'),
|
| 50 |
+
'align' => 'right',
|
| 51 |
+
'index' => 'reviews_count',
|
| 52 |
+
));
|
| 53 |
+
|
| 54 |
+
$this->addColumn('rating', array(
|
| 55 |
+
'header' => Mage::helper('snippet')->__('Ratings Summary'),
|
| 56 |
+
'align' => 'right',
|
| 57 |
+
'index' => 'rating',
|
| 58 |
+
));
|
| 59 |
+
|
| 60 |
+
$this->addColumn('from_price', array(
|
| 61 |
+
'header' => Mage::helper('snippet')->__('Start Price'),
|
| 62 |
+
'align' => 'right',
|
| 63 |
+
'index' => 'from_price',
|
| 64 |
+
));
|
| 65 |
+
|
| 66 |
+
$this->addColumn('action',
|
| 67 |
+
array(
|
| 68 |
+
'header' => Mage::helper('snippet')->__('Action'),
|
| 69 |
+
'width' => '100',
|
| 70 |
+
'type' => 'action',
|
| 71 |
+
'getter' => 'getId',
|
| 72 |
+
'actions' => array(
|
| 73 |
+
array(
|
| 74 |
+
'caption' => Mage::helper('snippet')->__('Edit'),
|
| 75 |
+
'url' => array('base' => '*/*/edit'),
|
| 76 |
+
'field' => 'id'
|
| 77 |
+
)),
|
| 78 |
+
'filter' => false,
|
| 79 |
+
'sortable' => false,
|
| 80 |
+
'index' => 'stores',
|
| 81 |
+
'is_system' => true,
|
| 82 |
+
));
|
| 83 |
+
return parent::_prepareColumns();
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* prepare mass action for this grid
|
| 88 |
+
*
|
| 89 |
+
* @return Magebuzz_Snippet_Block_Adminhtml_Snippet_Grid
|
| 90 |
+
*/
|
| 91 |
+
protected function _prepareMassaction()
|
| 92 |
+
{
|
| 93 |
+
$this->setMassactionIdField('snippet_id');
|
| 94 |
+
$this->getMassactionBlock()->setFormFieldName('snippet');
|
| 95 |
+
|
| 96 |
+
$statuses = Mage::getSingleton('snippet/status')->getOptionArray();
|
| 97 |
+
|
| 98 |
+
array_unshift($statuses, array('label' => '', 'value' => ''));
|
| 99 |
+
$this->getMassactionBlock()->addItem('', array(
|
| 100 |
+
'label' => Mage::helper('snippet')->__('No Action'),
|
| 101 |
+
));
|
| 102 |
+
return $this;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
public function getRowUrl($row)
|
| 106 |
+
{
|
| 107 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 108 |
+
}
|
| 109 |
+
}
|
app/code/local/Magebuzz/Snippet/Block/Breadcrumb.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Breadcrumb extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
public function _prepareLayout()
|
| 6 |
+
{
|
| 7 |
+
return parent::_prepareLayout();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function _construct()
|
| 11 |
+
{
|
| 12 |
+
$this->addData(array(
|
| 13 |
+
'cache_lifetime' => 86400,
|
| 14 |
+
'cache_tags' => array(Mage_Catalog_Model_Product::CACHE_TAG),
|
| 15 |
+
'cache_key' => $this->getProduct()->getId(),
|
| 16 |
+
));
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/local/Magebuzz/Snippet/Block/Category.php
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Category extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
public function _prepareLayout()
|
| 6 |
+
{
|
| 7 |
+
return parent::_prepareLayout();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function _construct()
|
| 11 |
+
{
|
| 12 |
+
$this->addData(array(
|
| 13 |
+
'cache_lifetime' => 86400,
|
| 14 |
+
'cache_tags' => array(Mage_Catalog_Model_Category::CACHE_TAG),
|
| 15 |
+
'cache_key' => Mage::registry('current_category')->getId(),
|
| 16 |
+
));
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public function getCategory() {
|
| 20 |
+
$currentCategory = Mage::registry('current_category');
|
| 21 |
+
$cate_id = $currentCategory->getId();
|
| 22 |
+
$_category = Mage::getModel('snippet/snippet')->load($cate_id, 'category_id');
|
| 23 |
+
return $_category;
|
| 24 |
+
}
|
| 25 |
+
}
|
app/code/local/Magebuzz/Snippet/Block/Organization.php
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Organization extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
public function _prepareLayout()
|
| 6 |
+
{
|
| 7 |
+
return parent::_prepareLayout();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function _construct()
|
| 11 |
+
{
|
| 12 |
+
$this->addData(array(
|
| 13 |
+
'cache_lifetime' => 86400,
|
| 14 |
+
));
|
| 15 |
+
}
|
| 16 |
+
}
|
app/code/local/Magebuzz/Snippet/Block/Product.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Block_Product extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* prepare block's layout
|
| 7 |
+
*
|
| 8 |
+
* @return Magebuzz_Snippet_Block_Product
|
| 9 |
+
*/
|
| 10 |
+
public function _prepareLayout()
|
| 11 |
+
{
|
| 12 |
+
return parent::_prepareLayout();
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
public function getProduct()
|
| 16 |
+
{
|
| 17 |
+
return Mage::registry('product');
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
protected function _construct()
|
| 21 |
+
{
|
| 22 |
+
$this->addData(array(
|
| 23 |
+
'cache_lifetime' => 86400,
|
| 24 |
+
'cache_tags' => array(Mage_Catalog_Model_Product::CACHE_TAG),
|
| 25 |
+
'cache_key' => $this->getProduct()->getId(),
|
| 26 |
+
));
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
}
|
app/code/local/Magebuzz/Snippet/Helper/Data.php
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
//general configuration
|
| 6 |
+
public function isEnable()
|
| 7 |
+
{
|
| 8 |
+
return Mage::getStoreConfig('snippet/general/enabled');
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
//Product configuration
|
| 12 |
+
public function showPrice()
|
| 13 |
+
{
|
| 14 |
+
return Mage::getStoreConfig('snippet/product/price');
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
public function showAvailability()
|
| 18 |
+
{
|
| 19 |
+
return Mage::getStoreConfig('snippet/product/availability');
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
public function showRatings()
|
| 23 |
+
{
|
| 24 |
+
return Mage::getStoreConfig('snippet/product/ratings');
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
public function showDescription()
|
| 28 |
+
{
|
| 29 |
+
return Mage::getStoreConfig('snippet/product/description');
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
public function showImage()
|
| 33 |
+
{
|
| 34 |
+
return Mage::getStoreConfig('snippet/product/image');
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
//BreadCrumbs configuration
|
| 38 |
+
public function enableBreadcrumbs()
|
| 39 |
+
{
|
| 40 |
+
return Mage::getStoreConfig('snippet/link/breadcrumbs');
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
// Organization Configuration
|
| 44 |
+
public function showOrganization()
|
| 45 |
+
{
|
| 46 |
+
return Mage::getStoreConfig('snippet/organization/enabled');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function getName()
|
| 50 |
+
{
|
| 51 |
+
return Mage::getStoreConfig('snippet/organization/name');
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
public function getLogo()
|
| 55 |
+
{
|
| 56 |
+
return Mage::getStoreConfig('snippet/organization/logo');
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public function getStreet()
|
| 60 |
+
{
|
| 61 |
+
return Mage::getStoreConfig('snippet/organization/street');
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public function getTelephone()
|
| 65 |
+
{
|
| 66 |
+
return Mage::getStoreConfig('snipet/organization/telephone');
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
public function getLink()
|
| 70 |
+
{
|
| 71 |
+
return Mage::getStoreConfig('snippet/organization/link');
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
public function getPostalCode()
|
| 75 |
+
{
|
| 76 |
+
return Mage::getStoreConfig('snippet/organization/postalcode');
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
public function getRegion()
|
| 80 |
+
{
|
| 81 |
+
return Mage::getStoreConfig('snippet/organization/region');
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
public function getCountry()
|
| 85 |
+
{
|
| 86 |
+
return Mage::getStoreConfig('snippet/organization/country');
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
//Category Configuration
|
| 90 |
+
public function showCategory()
|
| 91 |
+
{
|
| 92 |
+
return Mage::getStoreConfig('snippet/category/enabled');
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
public function getChildCategory()
|
| 96 |
+
{
|
| 97 |
+
return Mage::getStoreConfig('snippet/category/child_category');
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
}
|
app/code/local/Magebuzz/Snippet/Model/Mysql4/Snippet.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Model_Mysql4_Snippet extends Mage_Core_Model_Mysql4_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
$this->_init('snippet/snippet', 'snippet_id');
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/local/Magebuzz/Snippet/Model/Mysql4/Snippet/Collection.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Model_Mysql4_Snippet_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('snippet/snippet');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/local/Magebuzz/Snippet/Model/Observer.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Model_Observer
|
| 4 |
+
{
|
| 5 |
+
public function controllerActionPredispatch($observer)
|
| 6 |
+
{
|
| 7 |
+
$action = $observer->getEvent()->getControllerAction();
|
| 8 |
+
return $this;
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/local/Magebuzz/Snippet/Model/Snippet.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Model_Snippet extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('snippet/snippet');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/local/Magebuzz/Snippet/Model/Status.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Model_Status extends Varien_Object
|
| 4 |
+
{
|
| 5 |
+
const STATUS_ENABLED = 1;
|
| 6 |
+
const STATUS_DISABLED = 2;
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* get model option as array
|
| 10 |
+
*
|
| 11 |
+
* @return array
|
| 12 |
+
*/
|
| 13 |
+
static public function getOptionArray()
|
| 14 |
+
{
|
| 15 |
+
return array(
|
| 16 |
+
self::STATUS_ENABLED => Mage::helper('snippet')->__('Enabled'),
|
| 17 |
+
self::STATUS_DISABLED => Mage::helper('snippet')->__('Disabled')
|
| 18 |
+
);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* get model option hash as array
|
| 23 |
+
*
|
| 24 |
+
* @return array
|
| 25 |
+
*/
|
| 26 |
+
static public function getOptionHash()
|
| 27 |
+
{
|
| 28 |
+
$options = array();
|
| 29 |
+
foreach (self::getOptionArray() as $value => $label) {
|
| 30 |
+
$options[] = array(
|
| 31 |
+
'value' => $value,
|
| 32 |
+
'label' => $label
|
| 33 |
+
);
|
| 34 |
+
}
|
| 35 |
+
return $options;
|
| 36 |
+
}
|
| 37 |
+
}
|
app/code/local/Magebuzz/Snippet/controllers/Adminhtml/SnippetController.php
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_Adminhtml_SnippetController extends Mage_Adminhtml_Controller_Action
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* init layout and set active for current menu
|
| 7 |
+
*
|
| 8 |
+
* @return Magebuzz_Snippet_Adminhtml_SnippetController
|
| 9 |
+
*/
|
| 10 |
+
protected function _initAction()
|
| 11 |
+
{
|
| 12 |
+
$this->loadLayout()
|
| 13 |
+
->_setActiveMenu('snippet/snippet')
|
| 14 |
+
->_addBreadcrumb(
|
| 15 |
+
Mage::helper('adminhtml')->__('Items Manager'),
|
| 16 |
+
Mage::helper('adminhtml')->__('Item Manager')
|
| 17 |
+
);
|
| 18 |
+
return $this;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* index action
|
| 23 |
+
*/
|
| 24 |
+
public function indexAction()
|
| 25 |
+
{
|
| 26 |
+
$this->_initAction();
|
| 27 |
+
$this->renderLayout();
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
public function newAction()
|
| 31 |
+
{
|
| 32 |
+
$category = Mage::getModel('snippet/snippet');
|
| 33 |
+
if (!$category->getId()) {
|
| 34 |
+
$this->_forward('update');
|
| 35 |
+
} else {
|
| 36 |
+
$this->_forward('create');
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
public function updateAction()
|
| 41 |
+
{
|
| 42 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 43 |
+
$snippet_table = Mage::getSingleton('core/resource')->getTableName('snippet');
|
| 44 |
+
$delete_sql = "delete from {$snippet_table}";
|
| 45 |
+
$write->query($delete_sql);
|
| 46 |
+
$this->_forward('create');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function createAction()
|
| 50 |
+
{
|
| 51 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 52 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 53 |
+
$reviews = Mage::getSingleton('core/resource')->getTableName('review_entity_summary');
|
| 54 |
+
$snippet_table = Mage::getSingleton('core/resource')->getTableName('snippet');
|
| 55 |
+
$product_category = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
| 56 |
+
$query = "SELECT " . $product_category . ".category_id, sum(reviews_count), avg(rating_summary)
|
| 57 |
+
FROM " . $reviews . " inner join " . $product_category . "
|
| 58 |
+
WHERE " . $reviews . ".entity_pk_value = " . $product_category . ".product_id and reviews_count != 0
|
| 59 |
+
group by " . $product_category . ".category_id";
|
| 60 |
+
$result = $read->query($query);
|
| 61 |
+
while ($row = $result->fetch()) {
|
| 62 |
+
$count = $row['sum(reviews_count)'];
|
| 63 |
+
$cate_count = $row['category_id'];
|
| 64 |
+
$rating = $row['avg(rating_summary)'];
|
| 65 |
+
|
| 66 |
+
$categoryModel = Mage::getModel('catalog/category')->load($cate_count);
|
| 67 |
+
$productColl = Mage::getModel('catalog/product')->getCollection()
|
| 68 |
+
->addCategoryFilter($categoryModel)
|
| 69 |
+
->addAttributeToFilter('price', array('gt' => 0))
|
| 70 |
+
->addAttributeToSort('price', 'asc')
|
| 71 |
+
->setPageSize(1)
|
| 72 |
+
->load();
|
| 73 |
+
$lowestProductPrice = 0;
|
| 74 |
+
if ($productColl->getFirstItem()->getId()) $lowestProductPrice = $productColl->getFirstItem()->getPrice();
|
| 75 |
+
|
| 76 |
+
$sql = "INSERT INTO {$snippet_table} (category_id, reviews_count, rating, from_price) VALUES(" . $cate_count . " , " . $count . " , " . $rating . " , " . $lowestProductPrice . ")";
|
| 77 |
+
$write->query($sql);
|
| 78 |
+
}
|
| 79 |
+
$this->_forward('parent');
|
| 80 |
+
$this->_redirect('*/*/');
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
public function parentAction()
|
| 84 |
+
{
|
| 85 |
+
$cou = array();
|
| 86 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 87 |
+
$category_table = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity');
|
| 88 |
+
$snippet_table = Mage::getSingleton('core/resource')->getTableName('snippet');
|
| 89 |
+
$query = "select level from {$category_table} where level > 1 group by level";
|
| 90 |
+
$result = $read->query($query);
|
| 91 |
+
while ($row = $result->fetch()) {
|
| 92 |
+
$count = $row['level'];
|
| 93 |
+
$cou[] = $count;
|
| 94 |
+
}
|
| 95 |
+
$level_cat = array_reverse($cou);
|
| 96 |
+
for ($i = 0; $i < count($level_cat) - 1; $i++) {
|
| 97 |
+
|
| 98 |
+
$collection = Mage::getModel('catalog/category')->getResourceCollection();
|
| 99 |
+
foreach ($collection->getItems() as $item) {
|
| 100 |
+
$sum = 0;
|
| 101 |
+
$price = array();
|
| 102 |
+
$sum_avg_rev = 0;
|
| 103 |
+
if ($item->getChildrenCount() > 0) {
|
| 104 |
+
$id = $item->getId();
|
| 105 |
+
$root = Mage::getModel('catalog/category')->load($id);
|
| 106 |
+
$subCat = explode(',', $root->getChildren());
|
| 107 |
+
|
| 108 |
+
$collection = $root
|
| 109 |
+
->getCollection()
|
| 110 |
+
->addAttributeToSelect("*")
|
| 111 |
+
->addAttributeToFilter('level', $level_cat[$i])
|
| 112 |
+
->addFieldToFilter("entity_id", array("in", $subCat));
|
| 113 |
+
foreach ($collection->getItems() as $cat) {
|
| 114 |
+
$id_cate = $cat->getId();
|
| 115 |
+
$categoryModel = Mage::getModel('catalog/category')->load($id_cate);
|
| 116 |
+
|
| 117 |
+
$productColl = Mage::getModel('catalog/product')->getCollection()
|
| 118 |
+
->addCategoryFilter($categoryModel)
|
| 119 |
+
->addAttributeToFilter('price', array('gt' => 0))
|
| 120 |
+
->addAttributeToSort('price', 'asc')
|
| 121 |
+
->setPageSize(1)
|
| 122 |
+
->load();
|
| 123 |
+
$lowestProductPrice = $productColl->getFirstItem()->getPrice();
|
| 124 |
+
if($lowestProductPrice > 0){
|
| 125 |
+
$price[] = $lowestProductPrice;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
$sql = "SELECT from_price FROM ".$snippet_table." WHERE category_id = ".$id_cate;
|
| 129 |
+
$_result = $read->query($sql);
|
| 130 |
+
while($_row = $_result->fetch())
|
| 131 |
+
{
|
| 132 |
+
$pri = $_row['from_price'];
|
| 133 |
+
}
|
| 134 |
+
$price[] = $pri;
|
| 135 |
+
|
| 136 |
+
$snip = Mage::getModel('snippet/snippet')->getCollection();
|
| 137 |
+
foreach ($snip as $snippet) {
|
| 138 |
+
if ($snippet->getCategoryId() == $id_cate) {
|
| 139 |
+
$review = $snippet->getReviewsCount();
|
| 140 |
+
$sum += $review;
|
| 141 |
+
$rating = $snippet->getRating();
|
| 142 |
+
$sum_avg_rev += $review*$rating;
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
if ($sum > 0) {
|
| 147 |
+
if(Mage::helper('snippet')->getChildCategory())
|
| 148 |
+
{
|
| 149 |
+
$avg = round($sum_avg_rev/$sum);
|
| 150 |
+
$_pri = min($price);
|
| 151 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 152 |
+
$reviews = Mage::getSingleton('core/resource')->getTableName('review_entity_summary');
|
| 153 |
+
$product_category = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
| 154 |
+
$query = "SELECT sum(reviews_count), avg(rating_summary), category_id
|
| 155 |
+
FROM " . $reviews . " inner join " . $product_category . "
|
| 156 |
+
WHERE " . $reviews . ".entity_pk_value = " . $product_category . ".product_id and reviews_count != 0 and
|
| 157 |
+
category_id = " . $id . "
|
| 158 |
+
group by " . $product_category . ".category_id";
|
| 159 |
+
$result = $read->query($query);
|
| 160 |
+
while ($row = $result->fetch()) {
|
| 161 |
+
if(isset($row['category_id']) && $row['category_id'] == $id){
|
| 162 |
+
$sum_review_count = $row['sum(reviews_count)'];
|
| 163 |
+
$avg_rating_summary = $row['avg(rating_summary)'];
|
| 164 |
+
$sum += $sum_review_count;
|
| 165 |
+
$avg = round(($sum_review_count* $avg_rating_summary + $sum_avg_rev)/$sum);
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
$categoryModel = Mage::getModel('catalog/category')->load($id);
|
| 170 |
+
$productColl = Mage::getModel('catalog/product')->getCollection()
|
| 171 |
+
->addCategoryFilter($categoryModel)
|
| 172 |
+
->addAttributeToFilter('price', array('gt' => 0))
|
| 173 |
+
->addAttributeToSort('price', 'asc')
|
| 174 |
+
->setPageSize(1)
|
| 175 |
+
->load();
|
| 176 |
+
$lowestProductPrice = $productColl->getFirstItem()->getPrice();
|
| 177 |
+
if (($lowestProductPrice) > 0 && ($lowestProductPrice < $_pri)) {
|
| 178 |
+
$_pri = $lowestProductPrice;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 182 |
+
$_sql = " DELETE FROM {$snippet_table} where category_id = " . $id;
|
| 183 |
+
$write->query($_sql);
|
| 184 |
+
|
| 185 |
+
$_snippet = Mage::getModel('snippet/snippet');
|
| 186 |
+
$_snippet->setData('category_id', $id);
|
| 187 |
+
$_snippet->setData('reviews_count', $sum);
|
| 188 |
+
$_snippet->setData('rating', $avg);
|
| 189 |
+
$_snippet->setData('from_price', $_pri);
|
| 190 |
+
$_snippet->save();
|
| 191 |
+
}else{
|
| 192 |
+
$categoryModel = Mage::getModel('catalog/category')->load($id);
|
| 193 |
+
$productColl = Mage::getModel('catalog/product')->getCollection()
|
| 194 |
+
->addCategoryFilter($categoryModel)
|
| 195 |
+
->addAttributeToFilter('price', array('gt' => 0))
|
| 196 |
+
->addAttributeToSort('price', 'asc')
|
| 197 |
+
->setPageSize(1)
|
| 198 |
+
->load();
|
| 199 |
+
$lowestProductPrice = $productColl->getFirstItem()->getPrice();
|
| 200 |
+
|
| 201 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 202 |
+
$snippet_table = Mage::getSingleton('core/resource')->getTableName('snippet');
|
| 203 |
+
|
| 204 |
+
$_sql = " DELETE FROM {$snippet_table} where category_id = " . $id;
|
| 205 |
+
$write->query($_sql);
|
| 206 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 207 |
+
$reviews = Mage::getSingleton('core/resource')->getTableName('review_entity_summary');
|
| 208 |
+
$product_category = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
| 209 |
+
|
| 210 |
+
$query = "SELECT " . $product_category . ".category_id, sum(reviews_count), avg(rating_summary)
|
| 211 |
+
FROM " . $reviews . " inner join " . $product_category . "
|
| 212 |
+
WHERE " . $reviews . ".entity_pk_value = " . $product_category . ".product_id and reviews_count != 0 and
|
| 213 |
+
".$product_category.".category_id = ". $id."
|
| 214 |
+
group by " . $product_category . ".category_id";
|
| 215 |
+
$result = $read->query($query);
|
| 216 |
+
while ($row = $result->fetch()) {
|
| 217 |
+
$count = $row['sum(reviews_count)'];
|
| 218 |
+
$rating = $row['avg(rating_summary)'];
|
| 219 |
+
|
| 220 |
+
$_snippet = Mage::getModel('snippet/snippet');
|
| 221 |
+
$_snippet->setData('category_id', $id);
|
| 222 |
+
$_snippet->setData('reviews_count', $count);
|
| 223 |
+
$_snippet->setData('rating', $rating);
|
| 224 |
+
$_snippet->setData('from_price', $lowestProductPrice);
|
| 225 |
+
|
| 226 |
+
$_snippet->save();
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
$this->_forward('getcategoryzero');
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
public function getcategoryzeroAction()
|
| 237 |
+
{
|
| 238 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 239 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 240 |
+
$table_category = Mage::getSingleton('core/resource')->getTableName('catalog_category_entity');
|
| 241 |
+
$table_snippet = Mage::getSingleton('core/resource')->getTableName('snippet');
|
| 242 |
+
$sql = "SELECT distinct ". $table_category .".entity_id
|
| 243 |
+
FROM ".$table_category ."
|
| 244 |
+
WHERE ".$table_category.".entity_id NOT IN (SELECT category_id FROM ".$table_snippet." ) and entity_id > 1
|
| 245 |
+
";
|
| 246 |
+
$result = $read->query($sql);
|
| 247 |
+
while($row = $result->fetch())
|
| 248 |
+
{
|
| 249 |
+
$id = $row['entity_id'];
|
| 250 |
+
$categoryModel = Mage::getModel('catalog/category')->load($id);
|
| 251 |
+
$productColl = Mage::getModel('catalog/product')->getCollection()
|
| 252 |
+
->addCategoryFilter($categoryModel)
|
| 253 |
+
->addAttributeToFilter('price', array('gt' => 0))
|
| 254 |
+
->addAttributeToSort('price', 'asc')
|
| 255 |
+
->setPageSize(1)
|
| 256 |
+
->load();
|
| 257 |
+
$lowestProductPrice = 0;
|
| 258 |
+
if ($productColl->getFirstItem()->getId()) $lowestProductPrice = $productColl->getFirstItem()->getPrice();
|
| 259 |
+
|
| 260 |
+
$count = 0;
|
| 261 |
+
$rating = 0;
|
| 262 |
+
$sql = "INSERT INTO {$table_snippet} (category_id, reviews_count, rating, from_price) VALUES(" . $id . " ,
|
| 263 |
+
" . $count . " , " . $rating . " , " . $lowestProductPrice . ")";
|
| 264 |
+
$write->query($sql);
|
| 265 |
+
}
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
public function editAction()
|
| 269 |
+
{
|
| 270 |
+
$snippetId = $this->getRequest()->getParam('id');
|
| 271 |
+
$model = Mage::getModel('snippet/snippet')->load($snippetId);
|
| 272 |
+
|
| 273 |
+
if ($model->getId() || $snippetId == 0) {
|
| 274 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
| 275 |
+
if (!empty($data)) {
|
| 276 |
+
$model->setData($data);
|
| 277 |
+
}
|
| 278 |
+
Mage::register('snippet_data', $model);
|
| 279 |
+
|
| 280 |
+
$this->loadLayout();
|
| 281 |
+
$this->_setActiveMenu('snippet/snippet');
|
| 282 |
+
|
| 283 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
| 284 |
+
$this->_addContent($this->getLayout()->createBlock('snippet/adminhtml_snippet_edit'))
|
| 285 |
+
->_addLeft($this->getLayout()->createBlock('snippet/adminhtml_snippet_edit_tabs'));
|
| 286 |
+
|
| 287 |
+
$this->renderLayout();
|
| 288 |
+
} else {
|
| 289 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
| 290 |
+
Mage::helper('snippet')->__('Item does not exist')
|
| 291 |
+
);
|
| 292 |
+
$this->_redirect('*/*/');
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
public function saveAction()
|
| 297 |
+
{
|
| 298 |
+
if ($data = $this->getRequest()->getPost()) {
|
| 299 |
+
|
| 300 |
+
$model = Mage::getModel('snippet/snippet');
|
| 301 |
+
$model->setData($data)
|
| 302 |
+
->setId($this->getRequest()->getParam('id'));
|
| 303 |
+
|
| 304 |
+
try {
|
| 305 |
+
$model->save();
|
| 306 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 307 |
+
Mage::helper('snippet')->__('Item was successfully saved')
|
| 308 |
+
);
|
| 309 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
| 310 |
+
|
| 311 |
+
if ($this->getRequest()->getParam('back')) {
|
| 312 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
| 313 |
+
return;
|
| 314 |
+
}
|
| 315 |
+
$this->_redirect('*/*/');
|
| 316 |
+
return;
|
| 317 |
+
} catch (Exception $e) {
|
| 318 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 319 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
| 320 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 321 |
+
return;
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
| 325 |
+
Mage::helper('snippet')->__('Unable to find item to save')
|
| 326 |
+
);
|
| 327 |
+
$this->_redirect('*/*/');
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
/* protected function _isAllowed()
|
| 331 |
+
{
|
| 332 |
+
return Mage::getSingleton('admin/session')->isAllowed('snippet');
|
| 333 |
+
}*/
|
| 334 |
+
}
|
app/code/local/Magebuzz/Snippet/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Magebuzz_Snippet_IndexController extends Mage_Core_Controller_Front_Action
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* index action
|
| 7 |
+
*/
|
| 8 |
+
public function indexAction()
|
| 9 |
+
{
|
| 10 |
+
$this->loadLayout();
|
| 11 |
+
$this->renderLayout();
|
| 12 |
+
}
|
| 13 |
+
}
|
app/code/local/Magebuzz/Snippet/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" ?>
|
| 2 |
+
<config>
|
| 3 |
+
<menu>
|
| 4 |
+
<snippet module="snippet" translate="title">
|
| 5 |
+
<title>Rich Snippet</title>
|
| 6 |
+
<sort_order>71</sort_order>
|
| 7 |
+
<children>
|
| 8 |
+
<snippet module="snippet" translate="title">
|
| 9 |
+
<title>Generate Category Structured Data</title>
|
| 10 |
+
<sort_order>0</sort_order>
|
| 11 |
+
<action>snippetadmin/adminhtml_snippet</action>
|
| 12 |
+
</snippet>
|
| 13 |
+
<settings module="snippet" translate="title">
|
| 14 |
+
<title>Configuration</title>
|
| 15 |
+
<sort_order>1000</sort_order>
|
| 16 |
+
<action>adminhtml/system_config/edit/section/snippet</action>
|
| 17 |
+
</settings>
|
| 18 |
+
</children>
|
| 19 |
+
</snippet>
|
| 20 |
+
</menu>
|
| 21 |
+
<acl>
|
| 22 |
+
<resources>
|
| 23 |
+
<all>
|
| 24 |
+
<title>Allow Everything</title>
|
| 25 |
+
</all>
|
| 26 |
+
<admin>
|
| 27 |
+
<children>
|
| 28 |
+
<system>
|
| 29 |
+
<children>
|
| 30 |
+
<config>
|
| 31 |
+
<children>
|
| 32 |
+
<snippet module="snippet" translate="title">
|
| 33 |
+
<title>Rich Snippet</title>
|
| 34 |
+
<sort_order>71</sort_order>
|
| 35 |
+
</snippet>
|
| 36 |
+
</children>
|
| 37 |
+
</config>
|
| 38 |
+
</children>
|
| 39 |
+
</system>
|
| 40 |
+
<snippet module="snippet" translate="title">
|
| 41 |
+
<title>Snippet</title>
|
| 42 |
+
<sort_order>71</sort_order>
|
| 43 |
+
<children>
|
| 44 |
+
<snippet module="snippet" translate="title">
|
| 45 |
+
<title>Generate Category Structured Data</title>
|
| 46 |
+
<sort_order>0</sort_order>
|
| 47 |
+
</snippet>
|
| 48 |
+
<settings module="snippet" translate="title">
|
| 49 |
+
<title>Configuration</title>
|
| 50 |
+
<sort_order>1000</sort_order>
|
| 51 |
+
</settings>
|
| 52 |
+
</children>
|
| 53 |
+
</snippet>
|
| 54 |
+
</children>
|
| 55 |
+
</admin>
|
| 56 |
+
</resources>
|
| 57 |
+
</acl>
|
| 58 |
+
</config>
|
app/code/local/Magebuzz/Snippet/etc/config.xml
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" ?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Magebuzz_Snippet>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Magebuzz_Snippet>
|
| 7 |
+
</modules>
|
| 8 |
+
<frontend>
|
| 9 |
+
<routers>
|
| 10 |
+
<snippet>
|
| 11 |
+
<use>standard</use>
|
| 12 |
+
<args>
|
| 13 |
+
<module>Magebuzz_Snippet</module>
|
| 14 |
+
<frontName>snippet</frontName>
|
| 15 |
+
</args>
|
| 16 |
+
</snippet>
|
| 17 |
+
</routers>
|
| 18 |
+
<layout>
|
| 19 |
+
<updates>
|
| 20 |
+
<snippet>
|
| 21 |
+
<file>snippet.xml</file>
|
| 22 |
+
</snippet>
|
| 23 |
+
</updates>
|
| 24 |
+
</layout>
|
| 25 |
+
<translate>
|
| 26 |
+
<modules>
|
| 27 |
+
<Magebuzz_Snippet>
|
| 28 |
+
<files>
|
| 29 |
+
<default>Magebuzz_Snippet.csv</default>
|
| 30 |
+
</files>
|
| 31 |
+
</Magebuzz_Snippet>
|
| 32 |
+
</modules>
|
| 33 |
+
</translate>
|
| 34 |
+
</frontend>
|
| 35 |
+
<admin>
|
| 36 |
+
<routers>
|
| 37 |
+
<snippetadmin>
|
| 38 |
+
<use>admin</use>
|
| 39 |
+
<args>
|
| 40 |
+
<module>Magebuzz_Snippet</module>
|
| 41 |
+
<frontName>snippetadmin</frontName>
|
| 42 |
+
</args>
|
| 43 |
+
</snippetadmin>
|
| 44 |
+
</routers>
|
| 45 |
+
</admin>
|
| 46 |
+
<adminhtml>
|
| 47 |
+
<layout>
|
| 48 |
+
<updates>
|
| 49 |
+
<snippet>
|
| 50 |
+
<file>snippet.xml</file>
|
| 51 |
+
</snippet>
|
| 52 |
+
</updates>
|
| 53 |
+
</layout>
|
| 54 |
+
<translate>
|
| 55 |
+
<modules>
|
| 56 |
+
<Magebuzz_Snippet>
|
| 57 |
+
<files>
|
| 58 |
+
<default>Magebuzz_Snippet.csv</default>
|
| 59 |
+
</files>
|
| 60 |
+
</Magebuzz_Snippet>
|
| 61 |
+
</modules>
|
| 62 |
+
</translate>
|
| 63 |
+
</adminhtml>
|
| 64 |
+
<global>
|
| 65 |
+
<models>
|
| 66 |
+
<snippet>
|
| 67 |
+
<class>Magebuzz_Snippet_Model</class>
|
| 68 |
+
<resourceModel>snippet_mysql4</resourceModel>
|
| 69 |
+
</snippet>
|
| 70 |
+
<snippet_mysql4>
|
| 71 |
+
<class>Magebuzz_Snippet_Model_Mysql4</class>
|
| 72 |
+
<entities>
|
| 73 |
+
<snippet>
|
| 74 |
+
<table>snippet</table>
|
| 75 |
+
</snippet>
|
| 76 |
+
</entities>
|
| 77 |
+
</snippet_mysql4>
|
| 78 |
+
</models>
|
| 79 |
+
<resources>
|
| 80 |
+
<snippet_setup>
|
| 81 |
+
<setup>
|
| 82 |
+
<module>Magebuzz_Snippet</module>
|
| 83 |
+
</setup>
|
| 84 |
+
<connection>
|
| 85 |
+
<use>core_setup</use>
|
| 86 |
+
</connection>
|
| 87 |
+
</snippet_setup>
|
| 88 |
+
<snippet_write>
|
| 89 |
+
<connection>
|
| 90 |
+
<use>core_write</use>
|
| 91 |
+
</connection>
|
| 92 |
+
</snippet_write>
|
| 93 |
+
<snippet_read>
|
| 94 |
+
<connection>
|
| 95 |
+
<use>core_read</use>
|
| 96 |
+
</connection>
|
| 97 |
+
</snippet_read>
|
| 98 |
+
</resources>
|
| 99 |
+
<blocks>
|
| 100 |
+
<snippet>
|
| 101 |
+
<class>Magebuzz_Snippet_Block</class>
|
| 102 |
+
</snippet>
|
| 103 |
+
</blocks>
|
| 104 |
+
<helpers>
|
| 105 |
+
<snippet>
|
| 106 |
+
<class>Magebuzz_Snippet_Helper</class>
|
| 107 |
+
</snippet>
|
| 108 |
+
</helpers>
|
| 109 |
+
</global>
|
| 110 |
+
<default>
|
| 111 |
+
<snippet>
|
| 112 |
+
<general>
|
| 113 |
+
<enabled>1</enabled>
|
| 114 |
+
</general>
|
| 115 |
+
<product>
|
| 116 |
+
<price>1</price>
|
| 117 |
+
<availability>1</availability>
|
| 118 |
+
<ratings>1</ratings>
|
| 119 |
+
<description>1</description>
|
| 120 |
+
<image>1</image>
|
| 121 |
+
</product>
|
| 122 |
+
<link>
|
| 123 |
+
<breadcrumbs>1</breadcrumbs>
|
| 124 |
+
</link>
|
| 125 |
+
<organization>
|
| 126 |
+
<enabled>1</enabled>
|
| 127 |
+
</organization>
|
| 128 |
+
<category>
|
| 129 |
+
<enabled>1</enabled>
|
| 130 |
+
</category>
|
| 131 |
+
</snippet>
|
| 132 |
+
</default>
|
| 133 |
+
</config>
|
app/code/local/Magebuzz/Snippet/etc/system.xml
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" ?>
|
| 2 |
+
<config>
|
| 3 |
+
<tabs>
|
| 4 |
+
<magebuzz translate="label">
|
| 5 |
+
<label>Magebuzz Extension</label>
|
| 6 |
+
<sort_order>400</sort_order>
|
| 7 |
+
</magebuzz>
|
| 8 |
+
</tabs>
|
| 9 |
+
<sections>
|
| 10 |
+
<snippet translate="label" module="snippet">
|
| 11 |
+
<class>separator-top</class>
|
| 12 |
+
<label>Google Rich Snippet</label>
|
| 13 |
+
<tab>magebuzz</tab>
|
| 14 |
+
<frontend_type>text</frontend_type>
|
| 15 |
+
<sort_order>299</sort_order>
|
| 16 |
+
<show_in_default>1</show_in_default>
|
| 17 |
+
<show_in_website>1</show_in_website>
|
| 18 |
+
<show_in_store>1</show_in_store>
|
| 19 |
+
<groups>
|
| 20 |
+
<general translate="label">
|
| 21 |
+
<label>General Configuration</label>
|
| 22 |
+
<frontend_type>text</frontend_type>
|
| 23 |
+
<sort_order>1</sort_order>
|
| 24 |
+
<show_in_default>1</show_in_default>
|
| 25 |
+
<show_in_website>1</show_in_website>
|
| 26 |
+
<show_in_store>1</show_in_store>
|
| 27 |
+
<fields>
|
| 28 |
+
<enabled translate="label">
|
| 29 |
+
<label>Enable</label>
|
| 30 |
+
<frontend_type>select</frontend_type>
|
| 31 |
+
<sort_order>1</sort_order>
|
| 32 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 33 |
+
<show_in_default>1</show_in_default>
|
| 34 |
+
<show_in_website>1</show_in_website>
|
| 35 |
+
<show_in_store>1</show_in_store>
|
| 36 |
+
</enabled>
|
| 37 |
+
</fields>
|
| 38 |
+
</general>
|
| 39 |
+
|
| 40 |
+
<product translate="label">
|
| 41 |
+
<label>Product Information</label>
|
| 42 |
+
<frontend_type>text</frontend_type>
|
| 43 |
+
<sort_order>2</sort_order>
|
| 44 |
+
<show_in_default>1</show_in_default>
|
| 45 |
+
<show_in_website>1</show_in_website>
|
| 46 |
+
<show_in_store>1</show_in_store>
|
| 47 |
+
<fields>
|
| 48 |
+
<price translate="label">
|
| 49 |
+
<label>Show Product's Price</label>
|
| 50 |
+
<frontend_type>select</frontend_type>
|
| 51 |
+
<sort_order>1</sort_order>
|
| 52 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 53 |
+
<show_in_default>1</show_in_default>
|
| 54 |
+
<show_in_website>1</show_in_website>
|
| 55 |
+
<show_in_store>1</show_in_store>
|
| 56 |
+
</price>
|
| 57 |
+
<availability>
|
| 58 |
+
<label>Show Product's Stock Status</label>
|
| 59 |
+
<frontend_type>select</frontend_type>
|
| 60 |
+
<sort_order>2</sort_order>
|
| 61 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 62 |
+
<show_in_default>1</show_in_default>
|
| 63 |
+
<show_in_website>1</show_in_website>
|
| 64 |
+
<show_in_store>1</show_in_store>
|
| 65 |
+
</availability>
|
| 66 |
+
<ratings>
|
| 67 |
+
<label>Show Product's Rating</label>
|
| 68 |
+
<frontend_type>select</frontend_type>
|
| 69 |
+
<sort_order>3</sort_order>
|
| 70 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 71 |
+
<show_in_default>1</show_in_default>
|
| 72 |
+
<show_in_website>1</show_in_website>
|
| 73 |
+
<show_in_store>1</show_in_store>
|
| 74 |
+
</ratings>
|
| 75 |
+
<description>
|
| 76 |
+
<label>Show Product's Description</label>
|
| 77 |
+
<frontend_type>select</frontend_type>
|
| 78 |
+
<sort_order>4</sort_order>
|
| 79 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 80 |
+
<show_in_default>1</show_in_default>
|
| 81 |
+
<show_in_website>1</show_in_website>
|
| 82 |
+
<show_in_store>1</show_in_store>
|
| 83 |
+
</description>
|
| 84 |
+
<image>
|
| 85 |
+
<label>Show Product's Image</label>
|
| 86 |
+
<frontend_type>select</frontend_type>
|
| 87 |
+
<sort_order>5</sort_order>
|
| 88 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 89 |
+
<show_in_default>1</show_in_default>
|
| 90 |
+
<show_in_website>1</show_in_website>
|
| 91 |
+
<show_in_store>1</show_in_store>
|
| 92 |
+
</image>
|
| 93 |
+
</fields>
|
| 94 |
+
</product>
|
| 95 |
+
|
| 96 |
+
<link translate="label">
|
| 97 |
+
<label>Breadcrumbs</label>
|
| 98 |
+
<frontend_type>text</frontend_type>
|
| 99 |
+
<sort_order>3</sort_order>
|
| 100 |
+
<show_in_default>1</show_in_default>
|
| 101 |
+
<show_in_website>1</show_in_website>
|
| 102 |
+
<show_in_store>1</show_in_store>
|
| 103 |
+
<fields>
|
| 104 |
+
<breadcrumbs translate="label">
|
| 105 |
+
<label>Enable Breadcrumbs</label>
|
| 106 |
+
<frontend_type>select</frontend_type>
|
| 107 |
+
<sort_order>1</sort_order>
|
| 108 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 109 |
+
<show_in_default>1</show_in_default>
|
| 110 |
+
<show_in_website>1</show_in_website>
|
| 111 |
+
<show_in_store>1</show_in_store>
|
| 112 |
+
</breadcrumbs>
|
| 113 |
+
</fields>
|
| 114 |
+
</link>
|
| 115 |
+
|
| 116 |
+
<organization translate="label">
|
| 117 |
+
<label>Store Information</label>
|
| 118 |
+
<frontend_type>text</frontend_type>
|
| 119 |
+
<sort_order>4</sort_order>
|
| 120 |
+
<show_in_default>1</show_in_default>
|
| 121 |
+
<show_in_website>1</show_in_website>
|
| 122 |
+
<show_in_store>1</show_in_store>
|
| 123 |
+
<fields>
|
| 124 |
+
|
| 125 |
+
<enabled translate="label">
|
| 126 |
+
<label>Show Store Information</label>
|
| 127 |
+
<frontend_type>select</frontend_type>
|
| 128 |
+
<sort_order>1</sort_order>
|
| 129 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 130 |
+
<show_in_default>1</show_in_default>
|
| 131 |
+
<show_in_website>1</show_in_website>
|
| 132 |
+
<show_in_store>1</show_in_store>
|
| 133 |
+
</enabled>
|
| 134 |
+
|
| 135 |
+
<name translate="label">
|
| 136 |
+
<label>Name</label>
|
| 137 |
+
<frontend_type>text</frontend_type>
|
| 138 |
+
<sort_order>2</sort_order>
|
| 139 |
+
<show_in_default>1</show_in_default>
|
| 140 |
+
<show_in_website>1</show_in_website>
|
| 141 |
+
<show_in_store>1</show_in_store>
|
| 142 |
+
</name>
|
| 143 |
+
<logo translate="label">
|
| 144 |
+
<label>Logo</label>
|
| 145 |
+
<frontend_type>image</frontend_type>
|
| 146 |
+
<backend_model>adminhtml/system_config_backend_image_pdf</backend_model>
|
| 147 |
+
<upload_dir config="system/filesystem/media" scope_info="1">logo</upload_dir>
|
| 148 |
+
<base_url type="media" scope_info="1">logo</base_url>
|
| 149 |
+
<sort_order>3</sort_order>
|
| 150 |
+
<show_in_default>1</show_in_default>
|
| 151 |
+
<show_in_website>1</show_in_website>
|
| 152 |
+
<show_in_store>1</show_in_store>
|
| 153 |
+
</logo>
|
| 154 |
+
|
| 155 |
+
<street translate="label">
|
| 156 |
+
<label>Street Address</label>
|
| 157 |
+
<frontend_type>text</frontend_type>
|
| 158 |
+
<sort_order>4</sort_order>
|
| 159 |
+
<show_in_default>1</show_in_default>
|
| 160 |
+
<show_in_website>1</show_in_website>
|
| 161 |
+
<show_in_store>1</show_in_store>
|
| 162 |
+
<comment>ex:112 West 34th Street, 18th Flr</comment>
|
| 163 |
+
</street>
|
| 164 |
+
|
| 165 |
+
<telephone translate="label">
|
| 166 |
+
<label>Telephone</label>
|
| 167 |
+
<frontend_type>text</frontend_type>
|
| 168 |
+
<sort_order>5</sort_order>
|
| 169 |
+
<show_in_default>1</show_in_default>
|
| 170 |
+
<show_in_website>1</show_in_website>
|
| 171 |
+
<show_in_store>1</show_in_store>
|
| 172 |
+
<comment>ex: 555 999</comment>
|
| 173 |
+
</telephone>
|
| 174 |
+
|
| 175 |
+
<link translate="label">
|
| 176 |
+
<label>Link website</label>
|
| 177 |
+
<frontend_type>text</frontend_type>
|
| 178 |
+
<sort_order>6</sort_order>
|
| 179 |
+
<show_in_default>1</show_in_default>
|
| 180 |
+
<show_in_website>1</show_in_website>
|
| 181 |
+
<show_in_store>1</show_in_store>
|
| 182 |
+
<comment>ex:http://abc.com</comment>
|
| 183 |
+
</link>
|
| 184 |
+
|
| 185 |
+
<postalcode translate="label">
|
| 186 |
+
<label>Postal Code</label>
|
| 187 |
+
<frontend_type>text</frontend_type>
|
| 188 |
+
<sort_order>7</sort_order>
|
| 189 |
+
<show_in_default>1</show_in_default>
|
| 190 |
+
<show_in_website>1</show_in_website>
|
| 191 |
+
<show_in_store>1</show_in_store>
|
| 192 |
+
<comment>ex:10120</comment>
|
| 193 |
+
</postalcode>
|
| 194 |
+
|
| 195 |
+
<region translate="label">
|
| 196 |
+
<label>Region</label>
|
| 197 |
+
<frontend_type>text</frontend_type>
|
| 198 |
+
<sort_order>8</sort_order>
|
| 199 |
+
<show_in_default>1</show_in_default>
|
| 200 |
+
<show_in_website>1</show_in_website>
|
| 201 |
+
<show_in_store>1</show_in_store>
|
| 202 |
+
<comment>ex:New York</comment>
|
| 203 |
+
</region>
|
| 204 |
+
|
| 205 |
+
<country translate="label">
|
| 206 |
+
<label>Country Name</label>
|
| 207 |
+
<frontend_type>text</frontend_type>
|
| 208 |
+
<sort_order>9</sort_order>
|
| 209 |
+
<show_in_default>1</show_in_default>
|
| 210 |
+
<show_in_website>1</show_in_website>
|
| 211 |
+
<show_in_store>1</show_in_store>
|
| 212 |
+
<comment>ex:USA</comment>
|
| 213 |
+
</country>
|
| 214 |
+
</fields>
|
| 215 |
+
</organization>
|
| 216 |
+
|
| 217 |
+
<category translate="label">
|
| 218 |
+
<label>Category Information</label>
|
| 219 |
+
<frontend_type>text</frontend_type>
|
| 220 |
+
<sort_order>5</sort_order>
|
| 221 |
+
<show_in_default>1</show_in_default>
|
| 222 |
+
<show_in_website>1</show_in_website>
|
| 223 |
+
<show_in_store>1</show_in_store>
|
| 224 |
+
<fields>
|
| 225 |
+
<enabled translate="label">
|
| 226 |
+
<label>Enable</label>
|
| 227 |
+
<frontend_type>select</frontend_type>
|
| 228 |
+
<sort_order>1</sort_order>
|
| 229 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 230 |
+
<show_in_default>1</show_in_default>
|
| 231 |
+
<show_in_website>1</show_in_website>
|
| 232 |
+
<show_in_store>1</show_in_store>
|
| 233 |
+
</enabled>
|
| 234 |
+
|
| 235 |
+
<child_category>
|
| 236 |
+
<label>Enable recursive calculation for category</label>
|
| 237 |
+
<frontend_type>select</frontend_type>
|
| 238 |
+
<sort_order>2</sort_order>
|
| 239 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 240 |
+
<show_in_default>1</show_in_default>
|
| 241 |
+
<show_in_website>1</show_in_website>
|
| 242 |
+
<show_in_store>1</show_in_store>
|
| 243 |
+
<comment>If you select "YES ", all structured data of child-categories will be used to calculate structured data for parent category</comment>
|
| 244 |
+
</child_category>
|
| 245 |
+
</fields>
|
| 246 |
+
</category>
|
| 247 |
+
</groups>
|
| 248 |
+
</snippet>
|
| 249 |
+
</sections>
|
| 250 |
+
</config>
|
app/code/local/Magebuzz/Snippet/sql/snippet_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/** @var $installer Mage_Core_Model_Resource_Setup */
|
| 3 |
+
$installer = $this;
|
| 4 |
+
|
| 5 |
+
$installer->startSetup();
|
| 6 |
+
|
| 7 |
+
/**
|
| 8 |
+
* create snippet table
|
| 9 |
+
*/
|
| 10 |
+
$installer->run("
|
| 11 |
+
|
| 12 |
+
DROP TABLE IF EXISTS {$this->getTable('snippet')};
|
| 13 |
+
|
| 14 |
+
CREATE TABLE {$this->getTable('snippet')} (
|
| 15 |
+
`snippet_id` int(11) unsigned NOT NULL auto_increment,
|
| 16 |
+
`category_id` int(11) NOT NULL,
|
| 17 |
+
`category_name` varchar(255) NOT NULL,
|
| 18 |
+
`reviews_count` int(11) NOT NULL,
|
| 19 |
+
`rating` int(11) NOT NULL,
|
| 20 |
+
`from_price` decimal(12,4) NOT NULL,
|
| 21 |
+
PRIMARY KEY (`snippet_id`)
|
| 22 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 23 |
+
|
| 24 |
+
");
|
| 25 |
+
|
| 26 |
+
$installer->endSetup();
|
| 27 |
+
|
app/design/adminhtml/default/default/layout/snippet.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<snippetadmin_adminhtml_snippet_index>
|
| 4 |
+
<reference name="content">
|
| 5 |
+
<block type="snippet/adminhtml_snippet" name="snippet"/>
|
| 6 |
+
</reference>
|
| 7 |
+
</snippetadmin_adminhtml_snippet_index>
|
| 8 |
+
</layout>
|
app/design/frontend/base/default/layout/snippet.xml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<default>
|
| 4 |
+
<reference name="head">
|
| 5 |
+
<block type="snippet/organization" name="mr.snippet.organization.head"
|
| 6 |
+
template="snippet/organization.phtml"/>
|
| 7 |
+
</reference>
|
| 8 |
+
<reference name="breadcrumbs">
|
| 9 |
+
<action method="setTemplate">
|
| 10 |
+
<template>snippet/breadcrumbs.phtml</template>
|
| 11 |
+
</action>
|
| 12 |
+
</reference>
|
| 13 |
+
</default>
|
| 14 |
+
<catalog_product_view>
|
| 15 |
+
<reference name="before_body_end">
|
| 16 |
+
<block type="page/html_wrapper" name="product.info.addtocart.snippet.snippet">
|
| 17 |
+
<block type="snippet/product" name="snippet" template="snippet/product.phtml"/>
|
| 18 |
+
</block>
|
| 19 |
+
</reference>
|
| 20 |
+
</catalog_product_view>
|
| 21 |
+
|
| 22 |
+
<catalog_category_view>
|
| 23 |
+
<reference name="content">
|
| 24 |
+
<block type="snippet/category" name="snippet" template="snippet/category.phtml"/>
|
| 25 |
+
</reference>
|
| 26 |
+
</catalog_category_view>
|
| 27 |
+
|
| 28 |
+
</layout>
|
app/design/frontend/base/default/template/snippet/breadcrumbs.phtml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php if (isset($crumbs) && is_array($crumbs)): ?>
|
| 2 |
+
<?php if (Mage::helper('snippet')->enableBreadcrumbs()): ?>
|
| 3 |
+
<div class="breadcrumbs">
|
| 4 |
+
<ul>
|
| 5 |
+
<?php foreach ($crumbs as $_crumbName => $_crumbInfo): ?>
|
| 6 |
+
<li class="<?php echo $_crumbName ?>" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
|
| 7 |
+
<?php if ($_crumbInfo['link']): ?>
|
| 8 |
+
<a itemprop="url" href="<?php echo $_crumbInfo['link'] ?>"
|
| 9 |
+
title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><span
|
| 10 |
+
itemprop="title"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></span></a>
|
| 11 |
+
<?php elseif ($_crumbInfo['last']): ?>
|
| 12 |
+
<strong itemprop="title"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></strong>
|
| 13 |
+
<?php
|
| 14 |
+
else: ?>
|
| 15 |
+
<span itemprop="title"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></span>
|
| 16 |
+
<?php endif; ?>
|
| 17 |
+
<?php if (!$_crumbInfo['last']): ?>
|
| 18 |
+
<span>/ </span>
|
| 19 |
+
<?php endif; ?>
|
| 20 |
+
</li>
|
| 21 |
+
<?php endforeach; ?>
|
| 22 |
+
</ul>
|
| 23 |
+
</div>
|
| 24 |
+
<?php endif; ?>
|
| 25 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/snippet/category.phtml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php if (Mage::helper('snippet')->showCategory()): ?>
|
| 2 |
+
<?php
|
| 3 |
+
$_category = $this->getCategory();
|
| 4 |
+
if ($_category->getId()): ?>
|
| 5 |
+
<div itemscope itemtype="http://data-vocabulary.org/Review-aggregate">
|
| 6 |
+
<meta itemprop="itemreviewed" content="<?php echo Mage::registry('current_category')->getName() ?>"/>
|
| 7 |
+
<div itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating">
|
| 8 |
+
<meta itemprop="average" content="<?php echo $_category->getRating() / 10; ?>"/>
|
| 9 |
+
<meta itemprop="best" content="10"/>
|
| 10 |
+
</div>
|
| 11 |
+
<meta itemprop="votes" content="<?php echo ($vote = $_category->getReviewsCount()) ? $vote : 0; ?>"/>
|
| 12 |
+
</div>
|
| 13 |
+
<?php if($_category->getFromPrice() > 0): ?>
|
| 14 |
+
<div itemscope itemtype="http://data-vocabulary.org/Offer-aggregate">
|
| 15 |
+
<meta itemprop="currency" content="<?php echo Mage::app()->getStore()->getCurrentCurrencyCode() ?>"/>
|
| 16 |
+
<meta itemprop="lowprice" content="<?php echo round($_category->getFromPrice(), 2); ?>"/>
|
| 17 |
+
</div>
|
| 18 |
+
<?php endif; ?>
|
| 19 |
+
<?php else:
|
| 20 |
+
$cate_id = Mage::registry('current_category')->getId();
|
| 21 |
+
$categoryModel = Mage::getModel('catalog/category')->load($cate_id);
|
| 22 |
+
$productColl = Mage::getModel('catalog/product')->getCollection()
|
| 23 |
+
->addCategoryFilter($categoryModel)
|
| 24 |
+
->addAttributeToSort('price', 'asc')
|
| 25 |
+
->setPageSize(1)
|
| 26 |
+
->load();
|
| 27 |
+
$_lowestProductPrice = $productColl->getFirstItem()->getPrice();
|
| 28 |
+
?>
|
| 29 |
+
<div itemscope itemtype="http://data-vocabulary.org/Offer-aggregate">
|
| 30 |
+
<meta itemprop="currency" content="<?php echo Mage::app()->getStore()->getCurrentCurrencyCode() ?>"/>
|
| 31 |
+
<meta itemprop="lowprice" content="<?php echo round($_lowestProductPrice); ?>"/>
|
| 32 |
+
</div>
|
| 33 |
+
|
| 34 |
+
<?php endif; ?>
|
| 35 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/snippet/organization.phtml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php if (Mage::helper('snippet')->showOrganization()): ?>
|
| 2 |
+
<div itemscope itemtype="http://data-vocabulary.org/Organization" class="head">
|
| 3 |
+
<a itemprop="url" href="<?php if(Mage::helper('snippet')->getLink()){
|
| 4 |
+
echo Mage::helper('snippet')->getLink();
|
| 5 |
+
} else{
|
| 6 |
+
echo Mage::app()->getStore()->getHomeUrl();
|
| 7 |
+
}
|
| 8 |
+
?>">
|
| 9 |
+
<div itemprop="name">
|
| 10 |
+
<strong><?php if(Mage::helper('snippet')->getName()){
|
| 11 |
+
echo Mage::helper('snippet')->getName();
|
| 12 |
+
} else{
|
| 13 |
+
echo Mage::app()->getStore()->getName();
|
| 14 |
+
}
|
| 15 |
+
?></strong>
|
| 16 |
+
</div>
|
| 17 |
+
</a>
|
| 18 |
+
<meta itemprop="logo" content="<?php if(Mage::helper('snippet')->getLogo()){
|
| 19 |
+
echo $this->htmlEscape(Mage::helper('snippet')->getLogo());
|
| 20 |
+
} else{
|
| 21 |
+
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 22 |
+
}
|
| 23 |
+
?>"/>
|
| 24 |
+
<div itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">
|
| 25 |
+
<meta itemprop="street-address" content="<?php echo Mage::helper('snippet')->getStreet(); ?>"/>
|
| 26 |
+
<meta itemprop="postal-code" content="<?php echo Mage::helper('snippet')->getPostalCode(); ?>"/>
|
| 27 |
+
<meta itemprop="region" content="<?php echo Mage::helper('snippet')->getRegion(); ?>"/>
|
| 28 |
+
<meta itemprop="country-name" content="<?php echo Mage::helper('snippet')->getCountry(); ?>"/>
|
| 29 |
+
</div>
|
| 30 |
+
<meta itemprop="telephone" content="<?php echo Mage::helper('snippet')->getTelephone() ?>"/>
|
| 31 |
+
</div>
|
| 32 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/snippet/product.phtml
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
if (Mage::helper('snippet')->isEnable() && ($_product = $this->getProduct())):
|
| 3 |
+
$_helper = $this->helper('catalog/output');
|
| 4 |
+
?>
|
| 5 |
+
<div itemscope itemtype="http://schema.org/Product">
|
| 6 |
+
|
| 7 |
+
<meta itemprop="name" content="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
|
| 8 |
+
|
| 9 |
+
<?php if (Mage::helper('snippet')->showImage()) : ?>
|
| 10 |
+
<img itemprop="image" content="<?php echo Mage::helper('catalog/image')->init($_product, 'image') ?>"/>
|
| 11 |
+
<?php endif; ?>
|
| 12 |
+
|
| 13 |
+
<?php if (Mage::helper('snippet')->showDescription()) : ?>
|
| 14 |
+
<meta itemprop="description" content="<?php echo $this->htmlEscape($_product->getDescription()) ?>"/>
|
| 15 |
+
<?php endif; ?>
|
| 16 |
+
|
| 17 |
+
<?php if (Mage::helper('snippet')->showRatings()) : ?>
|
| 18 |
+
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
|
| 19 |
+
<meta itemprop="itemreviewed" content="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
|
| 20 |
+
<meta itemprop="reviewCount"
|
| 21 |
+
content="<?php echo ($reviewCount = $_product->getRatingSummary()->getReviewsCount()) ? $reviewCount : 0; ?>"/>
|
| 22 |
+
<?php $summaryData = Mage::getModel('review/review_summary')->setStoreId(Mage::app()->getStore()->getId())->load($_product->getId()); ?>
|
| 23 |
+
<meta itemprop="ratingValue"
|
| 24 |
+
content="<?php echo $this->htmlEscape($summaryData->getRatingSummary() * 5) / 100; ?>"/>
|
| 25 |
+
</div>
|
| 26 |
+
<?php endif; ?>
|
| 27 |
+
|
| 28 |
+
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
| 29 |
+
<?php if (Mage::helper('snippet')->showPrice()) : ?>
|
| 30 |
+
<meta itemprop="priceCurrency" content="<?php echo Mage::app()->getStore()->getCurrentCurrencyCode() ?>"/>
|
| 31 |
+
<meta itemprop="price" content="<?php echo round($_product->getFinalPrice()); ?>"/>
|
| 32 |
+
<?php endif; ?>
|
| 33 |
+
<?php if (Mage::helper('snippet')->showAvailability()) : ?>
|
| 34 |
+
<?php if ($_product->getIsInStock()) : ?>
|
| 35 |
+
<link itemprop="availability" content="InStock" href="http://schema.org/InStock">
|
| 36 |
+
<?php else: ?>
|
| 37 |
+
<link itemprop="availability" content="OutOfStock" href="http://schema.org/OutOfStock">
|
| 38 |
+
<?php endif; ?>
|
| 39 |
+
<?php endif; ?>
|
| 40 |
+
</div>
|
| 41 |
+
|
| 42 |
+
</div>
|
| 43 |
+
|
| 44 |
+
<?php endif; ?>
|
| 45 |
+
|
| 46 |
+
|
app/etc/modules/Magebuzz_Snippet.xml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Magebuzz_Snippet>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Catalog/>
|
| 9 |
+
<Mage_Review/>
|
| 10 |
+
</depends>
|
| 11 |
+
</Magebuzz_Snippet>
|
| 12 |
+
</modules>
|
| 13 |
+
</config>
|
app/locale/en_US/Magebuzz_Snippet.csv
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"Edit Category Id '%s'","Edit Category Id '%s'"
|
| 2 |
+
"Action","Action"
|
| 3 |
+
"Add Item","Add Item"
|
| 4 |
+
"All Category Reviews","All Category Reviews"
|
| 5 |
+
"Category ID","Category ID"
|
| 6 |
+
"Category Information","Category Information"
|
| 7 |
+
"Category Name","Category Name"
|
| 8 |
+
"Category information","Category information"
|
| 9 |
+
"Category","Category"
|
| 10 |
+
"Delete Current Data and Re-Generate","Delete Current Data and Re-Generate"
|
| 11 |
+
"Disabled","Disabled"
|
| 12 |
+
"Edit","Edit"
|
| 13 |
+
"Enabled","Enabled"
|
| 14 |
+
"Generate","Generate"
|
| 15 |
+
"Item Manager","Item Manager"
|
| 16 |
+
"Item does not exist","Item does not exist"
|
| 17 |
+
"Item was successfully saved","Item was successfully saved"
|
| 18 |
+
"Items Manager","Items Manager"
|
| 19 |
+
"No Action","No Action"
|
| 20 |
+
"Ratings Summary","Ratings Summary"
|
| 21 |
+
"Ratings","Ratings"
|
| 22 |
+
"Reviews Count","Reviews Count"
|
| 23 |
+
"Save Item","Save Item"
|
| 24 |
+
"Start Price","Start Price"
|
| 25 |
+
"Unable to find item to save","Unable to find item to save"
|
| 26 |
+
"Breadcrumbs","Breadcrumbs"
|
| 27 |
+
"Category Information","Category Information"
|
| 28 |
+
"Configuration","Configuration"
|
| 29 |
+
"Country Name","Country Name"
|
| 30 |
+
"Enable","Enable"
|
| 31 |
+
"Enable Breadcrumbs","Enable Breadcrumbs"
|
| 32 |
+
"General Configuration","General Configuration"
|
| 33 |
+
"Generate Category Structured Data","Generate Category Structured Data"
|
| 34 |
+
"Google Rich Snippet","Google Rich Snippet"
|
| 35 |
+
"Link website","Link website"
|
| 36 |
+
"Logo","Logo"
|
| 37 |
+
"Magebuzz Extension","Magebuzz Extension"
|
| 38 |
+
"Name","Name"
|
| 39 |
+
"Postal Code","Postal Code"
|
| 40 |
+
"Product Information","Product Information"
|
| 41 |
+
"Region","Region"
|
| 42 |
+
"Rich Snippet","Rich Snippet"
|
| 43 |
+
"Show Product's Price","Show Product's Price"
|
| 44 |
+
"Show Store Information","Show Store Information"
|
| 45 |
+
"Snippet","Snippet"
|
| 46 |
+
"Store Information","Store Information"
|
| 47 |
+
"Street Address","Street Address"
|
| 48 |
+
"Telephone","Telephone"
|
| 49 |
+
"Enable recursive calculation for category,"Enable recursive calculation for category"
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>magebuzz_google_rich_snippets</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Magebuzz Google Rich Snippet - 0.1.0 </summary>
|
| 10 |
+
<description>Magebuzz Google Rich Snippet - 0.1.0 </description>
|
| 11 |
+
<notes>Google Rich Snippets helps you highlight your products among search results of search engines by various types of rich snippets.</notes>
|
| 12 |
+
<authors><author><name>Magebuzz</name><user>magebuzz</user><email>magebuzz@gmail.com</email></author></authors>
|
| 13 |
+
<date>2016-02-05</date>
|
| 14 |
+
<time>08:57:53</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="Magebuzz"><dir name="Snippet"><dir name="Block"><dir name="Adminhtml"><dir name="Snippet"><dir name="Edit"><file name="Form.php" hash="b40e63d11ad9c10e7b27489e9cc5a054"/><dir name="Tab"><file name="Form.php" hash="e1efb96f85071c8b0d73a72b8bdfb274"/></dir><file name="Tabs.php" hash="303f9691a287d5c128a68815f48c6536"/></dir><file name="Edit.php" hash="339b53185a4bcd7f32af3b21b22e031f"/><file name="Grid.php" hash="89651c9ccf4ef900c2f648229ed1a81b"/></dir><file name="Snippet.php" hash="834f45f3ee6a0a46f1559ffe7df470c1"/></dir><file name="Breadcrumb.php" hash="c4aa84ee181c88ce48f8db61e398a71c"/><file name="Category.php" hash="8712b3be6c07a522511315e16043da0e"/><file name="Organization.php" hash="2ff62d9d6c4eb922f5756ed521db7126"/><file name="Product.php" hash="e1cf1f8e1010b3c7710b61261dcb3b49"/></dir><dir name="Helper"><file name="Data.php" hash="c221865cd7d3f5517b8452e832c6ea45"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Snippet"><file name="Collection.php" hash="0e57b92ffb3e79f40f4ad660fa3b7af1"/></dir><file name="Snippet.php" hash="414b426bafe0c8856ba68afe333f0bd6"/></dir><file name="Observer.php" hash="f55ed8b61394ef569d7cf8eaaceff5bd"/><file name="Snippet.php" hash="feca51c1c17f5f8a9bc524a539f7d28b"/><file name="Status.php" hash="6a5b05b2cea7e717253a66ff8aa71fcd"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SnippetController.php" hash="576bc30c510e8702fc10ed41784ef700"/></dir><file name="IndexController.php" hash="d08a527c265d0876bcccc1c70bbdc5e7"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4e01403000f73931fa75611a95a33923"/><file name="config.xml" hash="8e8a3a67528e3718eab72f828933e56c"/><file name="system.xml" hash="9f176f07223e6a02740cb4fb00307b8e"/></dir><dir name="sql"><dir name="snippet_setup"><file name="mysql4-install-0.1.0.php" hash="cafe0970254855e894ffb9ad8ef40418"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="snippet.xml" hash="07bb6fb759668e5d5f7c1f9ca06e6cf8"/></dir><dir name="template"><dir name="snippet"><file name="breadcrumbs.phtml" hash="13f599edf823c0ed596bd8556731f925"/><file name="category.phtml" hash="b2f69b44f20378f3f5c7ce61f2194711"/><file name="organization.phtml" hash="7cbc26993ff1bbc2233164d11cb064df"/><file name="product.phtml" hash="ca914ecb6cf313ff10d70c901eddb3a6"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="snippet.xml" hash="51c4007bf065f87224794c3f13f140a2"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Magebuzz_Snippet.csv" hash="e64cecac1a839518bb17ea0eca8ddcfd"/></dir></target><target name="mageetc"><dir name="modules"><file name="Magebuzz_Snippet.xml" hash="db722d061361ecdd4fccfdc11786a205"/></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
