alsoviewed - Version 1.0.0

Version Notes

Initial release

Download this release

Release Info

Developer Vova Yatsyuk
Extension alsoviewed
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (33) hide show
  1. app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Log.php +33 -0
  2. app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Log/Grid.php +53 -0
  3. app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Relations.php +33 -0
  4. app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Relations/Edit.php +64 -0
  5. app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Relations/Edit/Form.php +99 -0
  6. app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Relations/Grid.php +109 -0
  7. app/code/community/Yavva/Alsoviewed/Block/Products.php +127 -0
  8. app/code/community/Yavva/Alsoviewed/Helper/Data.php +6 -0
  9. app/code/community/Yavva/Alsoviewed/Model/Observer.php +51 -0
  10. app/code/community/Yavva/Alsoviewed/Model/Relation.php +69 -0
  11. app/code/community/Yavva/Alsoviewed/Model/Resource/Collection/Abstract.php +37 -0
  12. app/code/community/Yavva/Alsoviewed/Model/Resource/Log.php +63 -0
  13. app/code/community/Yavva/Alsoviewed/Model/Resource/Log/Collection.php +16 -0
  14. app/code/community/Yavva/Alsoviewed/Model/Resource/Relation.php +74 -0
  15. app/code/community/Yavva/Alsoviewed/Model/Resource/Relation/Collection.php +10 -0
  16. app/code/community/Yavva/Alsoviewed/Model/Session.php +32 -0
  17. app/code/community/Yavva/Alsoviewed/Model/System/Config/Source/ListMode.php +12 -0
  18. app/code/community/Yavva/Alsoviewed/controllers/Adminhtml/Alsoviewed/LogController.php +57 -0
  19. app/code/community/Yavva/Alsoviewed/controllers/Adminhtml/Alsoviewed/RelationsController.php +185 -0
  20. app/code/community/Yavva/Alsoviewed/etc/adminhtml.xml +78 -0
  21. app/code/community/Yavva/Alsoviewed/etc/config.xml +147 -0
  22. app/code/community/Yavva/Alsoviewed/etc/system.xml +208 -0
  23. app/code/community/Yavva/Alsoviewed/sql/yavva_alsoviewed_setup/install-1.0.0.php +81 -0
  24. app/design/adminhtml/base/default/layout/yavva/alsoviewed.xml +24 -0
  25. app/design/frontend/base/default/layout/yavva/alsoviewed.xml +74 -0
  26. app/design/frontend/base/default/template/yavva/alsoviewed/products.phtml +97 -0
  27. app/design/frontend/base/default/template/yavva/alsoviewed/wrapper/content.phtml +16 -0
  28. app/design/frontend/base/default/template/yavva/alsoviewed/wrapper/sidebar.phtml +18 -0
  29. app/etc/modules/Yavva_Alsoviewed.xml +11 -0
  30. app/locale/en_US/Yavva_Alsoviewed.csv +29 -0
  31. package.xml +25 -0
  32. skin/frontend/base/default/yavva/alsoviewed/.DS_Store +0 -0
  33. skin/frontend/base/default/yavva/alsoviewed/css/alsoviewed.css +78 -0
app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Log.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Block_Adminhtml_Log extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'alsoviewed';
8
+ $this->_controller = 'adminhtml_log';
9
+ $this->_headerText = Mage::helper('alsoviewed')->__('Log');
10
+
11
+ parent::__construct();
12
+
13
+ $this->_removeButton('add');
14
+
15
+ if ($this->_isAllowedAction('process')) {
16
+ $this->_addButton('process', array(
17
+ 'label' => Mage::helper('alsoviewed')->__('Process Log'),
18
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/process') .'\')'
19
+ ));
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Check permission for passed action
25
+ *
26
+ * @param string $action
27
+ * @return bool
28
+ */
29
+ protected function _isAllowedAction($action)
30
+ {
31
+ return Mage::getSingleton('admin/session')->isAllowed('yavva/alsoviewed/alsoviewed_log/' . $action);
32
+ }
33
+ }
app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Log/Grid.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Block_Adminhtml_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('alsoviewedLogGrid');
9
+ $this->setDefaultSort('entity_id');
10
+ $this->setDefaultDir('DESC');
11
+ }
12
+
13
+ protected function _prepareCollection()
14
+ {
15
+ $collection = Mage::getResourceModel('alsoviewed/log_collection')
16
+ ->addProductNamesToSelect();
17
+
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+
22
+ protected function _prepareColumns()
23
+ {
24
+ $this->addColumn('entity_id', array(
25
+ 'header' => Mage::helper('catalog')->__('ID'),
26
+ 'index' => 'entity_id',
27
+ 'width' => 50,
28
+ 'type' => 'number'
29
+ ));
30
+
31
+ $this->addColumn('product_name', array(
32
+ 'header' => Mage::helper('alsoviewed')->__('Product'),
33
+ 'index' => 'product_name'
34
+ ));
35
+
36
+ $this->addColumn('related_product_name', array(
37
+ 'header' => Mage::helper('adminhtml')->__('Related Product'),
38
+ 'index' => 'related_product_name'
39
+ ));
40
+
41
+ return parent::_prepareColumns();
42
+ }
43
+
44
+ /**
45
+ * Row click url
46
+ *
47
+ * @return string
48
+ */
49
+ public function getRowUrl($row)
50
+ {
51
+ return false;
52
+ }
53
+ }
app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Relations.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Block_Adminhtml_Relations extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'alsoviewed';
8
+ $this->_controller = 'adminhtml_relations';
9
+ $this->_headerText = Mage::helper('alsoviewed')->__('Relations');
10
+
11
+ parent::__construct();
12
+
13
+ $this->_removeButton('add');
14
+
15
+ if ($this->_isAllowedAction('save')) {
16
+ $this->_addButton('save', array(
17
+ 'label' => Mage::helper('alsoviewed')->__('Save'),
18
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/saveMultiple') .'\')'
19
+ ));
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Check permission for passed action
25
+ *
26
+ * @param string $action
27
+ * @return bool
28
+ */
29
+ protected function _isAllowedAction($action)
30
+ {
31
+ return Mage::getSingleton('admin/session')->isAllowed('yavva/alsoviewed/alsoviewed_relations/' . $action);
32
+ }
33
+ }
app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Relations/Edit.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Block_Adminhtml_Relations_Edit
4
+ extends Mage_Adminhtml_Block_Widget_Form_Container
5
+ {
6
+ public function __construct()
7
+ {
8
+ $this->_blockGroup = 'alsoviewed';
9
+ $this->_controller = 'adminhtml_relations';
10
+
11
+ parent::__construct();
12
+
13
+ if ($this->_isAllowedAction('delete')) {
14
+ $this->_addButton('delete_with_inverse', array(
15
+ 'label' => Mage::helper('alsoviewed')->__('Delete with inverse relation'),
16
+ 'class' => 'delete',
17
+ 'onclick' => 'deleteConfirm(\''. Mage::helper('adminhtml')->__('Are you sure you want to do this?')
18
+ .'\', \'' . $this->getDeleteWithInverseUrl() . '\')'
19
+ ), 0);
20
+ }
21
+ }
22
+
23
+ public function getDeleteWithInverseUrl()
24
+ {
25
+ return $this->getUrl('*/*/delete', array(
26
+ $this->_objectId => $this->getRequest()->getParam($this->_objectId),
27
+ 'inverse_relation' => 1
28
+ ));
29
+ }
30
+
31
+ public function getSaveUrl()
32
+ {
33
+ return $this->getUrl('*/*/save', array(
34
+ '_current' => true
35
+ ));
36
+ }
37
+
38
+ public function getRelation()
39
+ {
40
+ return Mage::registry('alsoviewed_relation');
41
+ }
42
+
43
+ public function getHeaderText()
44
+ {
45
+ if ($this->getRelation()->getId()) {
46
+ return Mage::helper('cms')->__(
47
+ "Edit Relation '%s'",
48
+ $this->escapeHtml($this->getRelation()->getName())
49
+ );
50
+ }
51
+ return Mage::helper('alsoviewed')->__('New Relation');
52
+ }
53
+
54
+ /**
55
+ * Check permission for passed action
56
+ *
57
+ * @param string $action
58
+ * @return bool
59
+ */
60
+ protected function _isAllowedAction($action)
61
+ {
62
+ return Mage::getSingleton('admin/session')->isAllowed('yavva/alsoviewed/alsoviewed_relations/' . $action);
63
+ }
64
+ }
app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Relations/Edit/Form.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Block_Adminhtml_Relations_Edit_Form
4
+ extends Mage_Adminhtml_Block_Widget_Form
5
+ {
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('relation_form');
10
+ }
11
+
12
+ protected function _prepareForm()
13
+ {
14
+ $model = Mage::registry('alsoviewed_relation');
15
+
16
+ $form = new Varien_Data_Form(
17
+ array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')
18
+ );
19
+
20
+ $form->setHtmlIdPrefix('relation_');
21
+
22
+ $fieldset = $form->addFieldset('base_fieldset', array(
23
+ 'legend' => Mage::helper('cms')->__('General Information'),
24
+ 'class' => 'fieldset-wide'
25
+ ));
26
+
27
+ if ($model->getId()) {
28
+ $fieldset->addField('relation_id', 'hidden', array(
29
+ 'name' => 'relation_id'
30
+ ));
31
+ $fieldset->addField('product_id', 'hidden', array(
32
+ 'name' => 'product_id'
33
+ ));
34
+ $fieldset->addField('related_product_id', 'hidden', array(
35
+ 'name' => 'related_product_id'
36
+ ));
37
+ }
38
+
39
+ $product = $model->getProduct();
40
+ $relatedProduct = $model->getRelatedProduct();
41
+ $fieldset->addField('relation', 'note', array(
42
+ 'label' => Mage::helper('alsoviewed')->__('Relation'),
43
+ 'text' => sprintf(
44
+ '<a href="%s" onclick="this.target=\'blank\'">%s</a> - <a href="%s" onclick="this.target=\'blank\'">%s</a>',
45
+ $this->getUrl('*/catalog_product/edit', array('id' => $product->getId())),
46
+ $product->getName(),
47
+ $this->getUrl('*/catalog_product/edit', array('id' => $relatedProduct->getId())),
48
+ $relatedProduct->getName()
49
+ )
50
+ ));
51
+
52
+ $fieldset->addField('position', 'text', array(
53
+ 'label' => Mage::helper('catalog')->__('Position'),
54
+ 'title' => Mage::helper('catalog')->__('Position'),
55
+ 'name' => 'position',
56
+ 'note' => Mage::helper('alsoviewed')->__(
57
+ 'Position is used to sort products manually'
58
+ ),
59
+ 'required' => true
60
+ ));
61
+
62
+ $fieldset->addField('weight', 'text', array(
63
+ 'label' => Mage::helper('sales')->__('Weight'),
64
+ 'title' => Mage::helper('sales')->__('Weight'),
65
+ 'name' => 'weight',
66
+ 'note' => Mage::helper('alsoviewed')->__(
67
+ 'Weight is automatically increased by module. It is highly recommended to not to change it, to see the actual popular relations'
68
+ ),
69
+ 'required' => true
70
+ ));
71
+
72
+ $fieldset->addField('status', 'select', array(
73
+ 'label' => Mage::helper('cms')->__('Status'),
74
+ 'title' => Mage::helper('cms')->__('Status'),
75
+ 'name' => 'status',
76
+ 'required' => true,
77
+ 'options' => array(
78
+ '1' => Mage::helper('cms')->__('Enabled'),
79
+ '0' => Mage::helper('cms')->__('Disabled')
80
+ )
81
+ ));
82
+ if (!$model->getId()) {
83
+ $model->setData('status', '1');
84
+ }
85
+
86
+ $fieldset->addField('inverse_relation', 'checkbox', array(
87
+ 'label' => Mage::helper('alsoviewed')->__('Apply the same values to the inverse relation'),
88
+ 'title' => Mage::helper('alsoviewed')->__('Apply the same values to the inverse relation'),
89
+ 'name' => 'inverse_relation',
90
+ 'value' => 1
91
+ ));
92
+
93
+ $form->setValues($model->getData());
94
+ $form->setUseContainer(true);
95
+ $this->setForm($form);
96
+
97
+ return parent::_prepareForm();
98
+ }
99
+ }
app/code/community/Yavva/Alsoviewed/Block/Adminhtml/Relations/Grid.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Block_Adminhtml_Relations_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('alsoviewedRelationsGrid');
9
+ $this->setDefaultSort('weight');
10
+ $this->setDefaultDir('DESC');
11
+ }
12
+
13
+ protected function _prepareCollection()
14
+ {
15
+ $collection = Mage::getResourceModel('alsoviewed/relation_collection')
16
+ ->addProductNamesToSelect();
17
+
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+
22
+ protected function _prepareColumns()
23
+ {
24
+ $this->addColumn('relation_id', array(
25
+ 'header' => Mage::helper('catalog')->__('ID'),
26
+ 'index' => 'relation_id',
27
+ 'width' => 50,
28
+ 'type' => 'number'
29
+ ));
30
+
31
+ $this->addColumn('product_name', array(
32
+ 'header' => Mage::helper('catalog')->__('Product'),
33
+ 'index' => 'product_name'
34
+ ));
35
+
36
+ $this->addColumn('related_product_name', array(
37
+ 'header' => Mage::helper('adminhtml')->__('Related Product'),
38
+ 'index' => 'related_product_name'
39
+ ));
40
+
41
+ $this->addColumn('weight', array(
42
+ 'header' => Mage::helper('sales')->__('Weight'),
43
+ 'index' => 'weight',
44
+ 'width' => 50,
45
+ 'type' => 'number'
46
+ ));
47
+
48
+ $this->addColumn('position', array(
49
+ 'header' => Mage::helper('adminhtml')->__('Position'),
50
+ 'index' => 'position',
51
+ 'width' => 50,
52
+ 'type' => 'number'
53
+ ));
54
+
55
+ $this->addColumn('status', array(
56
+ 'header' => Mage::helper('cms')->__('Status'),
57
+ 'index' => 'status',
58
+ 'type' => 'options',
59
+ 'width' => 150,
60
+ 'options' => array(
61
+ 0 => Mage::helper('cms')->__('Disabled'),
62
+ 1 => Mage::helper('cms')->__('Enabled')
63
+ )
64
+ ));
65
+
66
+ return parent::_prepareColumns();
67
+ }
68
+
69
+ /**
70
+ * Row click url
71
+ *
72
+ * @return string
73
+ */
74
+ public function getRowUrl($row)
75
+ {
76
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
77
+ }
78
+
79
+ protected function _prepareMassaction()
80
+ {
81
+ $this->setMassactionIdField('relation_id');
82
+ $this->getMassactionBlock()->setFormFieldName('relation_id');
83
+
84
+ $this->getMassactionBlock()->addItem('delete', array(
85
+ 'label' => Mage::helper('adminhtml')->__('Delete'),
86
+ 'url' => $this->getUrl('*/*/massDelete'),
87
+ 'confirm' => Mage::helper('adminhtml')->__('Are you sure?')
88
+ ));
89
+
90
+ $this->getMassactionBlock()->addItem('status', array(
91
+ 'label' => Mage::helper('catalog')->__('Change status'),
92
+ 'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
93
+ 'additional' => array(
94
+ 'visibility' => array(
95
+ 'name' => 'status',
96
+ 'type' => 'select',
97
+ 'class' => 'required-entry',
98
+ 'label' => Mage::helper('catalog')->__('Status'),
99
+ 'values' => array(
100
+ 0 => Mage::helper('cms')->__('Disabled'),
101
+ 1 => Mage::helper('cms')->__('Enabled')
102
+ )
103
+ )
104
+ )
105
+ ));
106
+
107
+ return $this;
108
+ }
109
+ }
app/code/community/Yavva/Alsoviewed/Block/Products.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Block_Products extends Mage_Catalog_Block_Product_Abstract
4
+ {
5
+ const DEFAULT_PRODUCTS_COUNT = 4;
6
+ const DEFAULT_IMAGE_WIDTH = 170;
7
+ const DEFAULT_IMAGE_HEIGHT = 170;
8
+
9
+ /**
10
+ * @var Mage_Catalog_Model_Resource_Product_Collection $_productCollection
11
+ */
12
+ protected $_productCollection = null;
13
+
14
+ /**
15
+ * Retrieve alsoviewed products collection
16
+ *
17
+ * @return Mage_Catalog_Model_Resource_Product_Collection
18
+ */
19
+ public function getProductCollection()
20
+ {
21
+ if (null === $this->_productCollection) {
22
+ $collection = Mage::getResourceModel('catalog/product_collection');
23
+ $collection->setVisibility(
24
+ Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds()
25
+ );
26
+
27
+ $collection = $this->_addProductAttributesAndPrices($collection)
28
+ ->addStoreFilter()
29
+ ->setPageSize($this->getProductsCount())
30
+ ->setCurPage(1);
31
+
32
+ $collection
33
+ ->joinTable(
34
+ array('alsoviewed' => 'alsoviewed/relation'),
35
+ 'related_product_id=entity_id',
36
+ array(
37
+ 'alsoviewed_weight' => 'weight',
38
+ 'alsoviewed_position' => 'position',
39
+ ),
40
+ array(
41
+ 'product_id' => $this->getProductId(),
42
+ 'status' => 1
43
+ ),
44
+ 'inner'
45
+ )
46
+ ->addAttributeToSort('alsoviewed_position', 'ASC')
47
+ ->addAttributeToSort('alsoviewed_weight', 'DESC');
48
+
49
+ $this->_productCollection = $collection;
50
+ }
51
+
52
+ return $this->_productCollection;
53
+ }
54
+
55
+ /**
56
+ * Retrieve product id
57
+ *
58
+ * @return integer
59
+ */
60
+ public function getProductId()
61
+ {
62
+ $id = $this->_getData('product_id');
63
+ if (null === $id) {
64
+ $product = Mage::registry('current_product');
65
+ if ($product) {
66
+ $id = $product->getId();
67
+ }
68
+ }
69
+ return $id;
70
+ }
71
+
72
+ /**
73
+ * Retrieve products count to show
74
+ *
75
+ * @return integer
76
+ */
77
+ public function getProductsCount()
78
+ {
79
+ $count = $this->_getData('products_count');
80
+ if (null === $count) {
81
+ return self::DEFAULT_PRODUCTS_COUNT;
82
+ }
83
+ return $count;
84
+ }
85
+
86
+ /**
87
+ * Retrieve image width
88
+ *
89
+ * @return integer
90
+ */
91
+ public function getImageWidth()
92
+ {
93
+ $width = $this->_getData('image_width');
94
+ if (null === $width) {
95
+ return self::DEFAULT_IMAGE_WIDTH;
96
+ }
97
+ return $width;
98
+ }
99
+
100
+ /**
101
+ * Retreive image height. This variable is nullable.
102
+ *
103
+ * @return mixed
104
+ */
105
+ public function getImageHeight()
106
+ {
107
+ $height = $this->_getData('image_height');
108
+ if (null === $height) {
109
+ return self::DEFAULT_IMAGE_HEIGHT;
110
+ }
111
+ return $height;
112
+ }
113
+
114
+ /**
115
+ * Used to setup the block from the layout file
116
+ *
117
+ * @param [type] $path [description]
118
+ */
119
+ public function addDataFromConfig($path)
120
+ {
121
+ $config = Mage::getStoreConfig($path);
122
+ if (is_array($config)) {
123
+ $this->addData($config);
124
+ }
125
+ return $this;
126
+ }
127
+ }
app/code/community/Yavva/Alsoviewed/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/Yavva/Alsoviewed/Model/Observer.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Model_Observer
4
+ {
5
+ protected function _getSession()
6
+ {
7
+ return Mage::getSingleton('alsoviewed/session');
8
+ }
9
+
10
+ /**
11
+ * Add product relations to alsoviewed_log table
12
+ *
13
+ * @param Varien_Event_Observer $observer
14
+ */
15
+ public function catalogProductView(Varien_Event_Observer $observer)
16
+ {
17
+ $session = $this->_getSession();
18
+ $productId = $observer->getControllerAction()->getRequest()->getParam('id');
19
+ $viewedIds = $session->getViewedProductIds();
20
+
21
+ if (!$viewedIds) {
22
+ $viewedIds = array();
23
+ }
24
+
25
+ if ($productId && !in_array($productId, $viewedIds)) {
26
+ if (count($viewedIds)) {
27
+ Mage::getResourceModel('alsoviewed/log')->insertRelations(
28
+ $productId, $viewedIds
29
+ );
30
+ }
31
+ $session->addViewedProductId($productId);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Move generated log records to alsoviewed_relation table
37
+ */
38
+ public function processLog()
39
+ {
40
+ $log = Mage::getResourceModel('alsoviewed/log');
41
+ $data = $log->getGroupedRelations();
42
+ if ($data) {
43
+ try {
44
+ Mage::getResourceModel('alsoviewed/relation')->updateRelations($data);
45
+ $log->clean();
46
+ } catch (Zend_Db_Exception $e) {
47
+ Mage::logException($e);
48
+ }
49
+ }
50
+ }
51
+ }
app/code/community/Yavva/Alsoviewed/Model/Relation.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Model_Relation extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('alsoviewed/relation');
8
+ }
9
+
10
+ /**
11
+ * Retrieve reverse relation model
12
+ *
13
+ * @return Yavva_Alsoviewed_Model_Relation
14
+ */
15
+ public function getInverseRelation()
16
+ {
17
+ $relation = $this->getData('inverse_relation');
18
+ if (null === $relation) {
19
+ $relation = $this->getCollection()
20
+ ->addFieldToFilter('product_id', $this->getRelatedProductId())
21
+ ->addFieldToFilter('related_product_id', $this->getProductId())
22
+ ->getFirstItem();
23
+
24
+ if (!$relation->getId()) {
25
+ $relation->setProductId($this->getRelatedProductId())
26
+ ->setRelatedProductId($this->getProductId());
27
+ }
28
+ $this->setData('inverse_relation', $relation);
29
+ }
30
+ return $relation;
31
+ }
32
+
33
+ /**
34
+ * Retrieve product collection with 2 related products
35
+ *
36
+ * @return Mage_Catalog_Model_Resource_Product_Collection
37
+ */
38
+ public function getProducts()
39
+ {
40
+ $products = $this->getData('products');
41
+ if (null === $products) {
42
+ $products = Mage::getResourceModel('catalog/product_collection')
43
+ ->addAttributeToSelect('name')
44
+ ->addFieldToFilter('entity_id', array(
45
+ 'in' => array(
46
+ $this->getProductId(),
47
+ $this->getRelatedProductId()
48
+ )
49
+ ));
50
+ $this->setData('products', $products);
51
+ }
52
+ return $products;
53
+ }
54
+
55
+ public function getProduct()
56
+ {
57
+ return $this->getProducts()->getItemById($this->getProductId());
58
+ }
59
+
60
+ public function getRelatedProduct()
61
+ {
62
+ return $this->getProducts()->getItemById($this->getRelatedProductId());
63
+ }
64
+
65
+ public function getName()
66
+ {
67
+ return $this->getProduct()->getName() . ' - ' . $this->getRelatedProduct()->getName();
68
+ }
69
+ }
app/code/community/Yavva/Alsoviewed/Model/Resource/Collection/Abstract.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Yavva_Alsoviewed_Model_Resource_Collection_Abstract
4
+ extends Mage_Core_Model_Resource_Db_Collection_Abstract
5
+ {
6
+ protected $_map = array('fields' => array(
7
+ 'product_name' => 'product_name.value',
8
+ 'related_product_name' => 'related_product_name.value'
9
+ ));
10
+
11
+ public function addProductNamesToSelect()
12
+ {
13
+ $attribute = Mage::getResourceModel('catalog/product_attribute_collection')
14
+ ->addFieldToFilter('attribute_code', 'name')
15
+ ->getFirstItem();
16
+ $tableName = Mage::getModel('core/resource')
17
+ ->getTableName('catalog_product_entity_varchar');
18
+
19
+ $this->getSelect()->join(
20
+ array('product_name' => $tableName),
21
+ 'product_id = product_name.entity_id',
22
+ array('product_name' => 'value')
23
+ )
24
+ ->where('product_name.store_id = ?', 0)
25
+ ->where('product_name.attribute_id = ?', $attribute->getId());
26
+
27
+ $this->getSelect()->join(
28
+ array('related_product_name' => $tableName),
29
+ 'related_product_id = related_product_name.entity_id',
30
+ array('related_product_name' => 'value')
31
+ )
32
+ ->where('related_product_name.store_id = ?', 0)
33
+ ->where('related_product_name.attribute_id = ?', $attribute->getId());
34
+
35
+ return $this;
36
+ }
37
+ }
app/code/community/Yavva/Alsoviewed/Model/Resource/Log.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Model_Resource_Log extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('alsoviewed/log', 'entity_id');
8
+ }
9
+
10
+ /**
11
+ * @param int $id Product Id
12
+ * @param array $ids Related Product Ids
13
+ * @return Yavva_Alsoviewed_Model_Resource_Log
14
+ */
15
+ public function insertRelations($id, $ids)
16
+ {
17
+ $insertData = array();
18
+ foreach ($ids as $relatedId) {
19
+ // All relations are bidirectional, so I can use the min and max to
20
+ // prevent duplicated relations in grouped by product_id columns query
21
+ // @see getGroupedRelations method
22
+ $insertData[] = array(
23
+ 'product_id' => min($id, $relatedId),
24
+ 'related_product_id' => max($id, $relatedId)
25
+ );
26
+ }
27
+ $this->_getWriteAdapter()->insertMultiple(
28
+ $this->getMainTable(), $insertData
29
+ );
30
+
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Retrieve product relations with weight
36
+ *
37
+ * @return array
38
+ */
39
+ public function getGroupedRelations()
40
+ {
41
+ $adapter = $this->_getReadAdapter();
42
+ $select = $adapter->select()
43
+ ->from($this->getMainTable(), array(
44
+ 'product_id',
45
+ 'related_product_id',
46
+ 'weight' => 'COUNT(entity_id)'
47
+ ))
48
+ ->group(array('product_id', 'related_product_id'));
49
+
50
+ return $adapter->fetchAll($select);
51
+ }
52
+
53
+ /**
54
+ * Remove records from table
55
+ *
56
+ * @param array $where
57
+ * @return Number of affected rows
58
+ */
59
+ public function clean($where = '')
60
+ {
61
+ return $this->_getWriteAdapter()->delete($this->getMainTable(), $where);
62
+ }
63
+ }
app/code/community/Yavva/Alsoviewed/Model/Resource/Log/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Model_Resource_Log_Collection extends Yavva_Alsoviewed_Model_Resource_Collection_Abstract
4
+ {
5
+ protected $_map = array('fields' => array(
6
+ 'entity_id' => 'main_table.entity_id',
7
+ 'product_name' => 'product_name.value',
8
+ 'related_product_name' => 'related_product_name.value'
9
+ ));
10
+
11
+ protected function _construct()
12
+ {
13
+ $this->_init('alsoviewed/log');
14
+ $this->setItemObjectClass('Varien_Object');
15
+ }
16
+ }
app/code/community/Yavva/Alsoviewed/Model/Resource/Relation.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Model_Resource_Relation extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('alsoviewed/relation', 'relation_id');
8
+ }
9
+
10
+ /**
11
+ * Insert new and update existing relations according to $relationsData
12
+ * Unlike the updateMultiple, this method adds saved relation weight
13
+ * with the weight from $relationsData.
14
+ *
15
+ * @param array $relationsData Array of product to product relations:
16
+ * array(
17
+ * array(
18
+ * product_id => int
19
+ * related_product_id => int
20
+ * weight => int
21
+ * )
22
+ * ...
23
+ * )
24
+ * @param boolean $bidirectional
25
+ * @return int Number of affected rows
26
+ */
27
+ public function updateRelations($relationsData, $bidirectional = true)
28
+ {
29
+ $data = $relationsData;
30
+ if ($bidirectional) {
31
+ foreach ($relationsData as $relation) {
32
+ $data[] = array(
33
+ 'product_id' => $relation['related_product_id'],
34
+ 'related_product_id' => $relation['product_id'],
35
+ 'weight' => $relation['weight']
36
+ );
37
+ }
38
+ }
39
+
40
+ $adapter = $this->_getWriteAdapter();
41
+ return $adapter->insertOnDuplicate($this->getMainTable(), $data, array(
42
+ 'weight' => new Zend_Db_Expr('weight + VALUES(weight)')
43
+ ));
44
+ }
45
+
46
+ /**
47
+ * Update multiple relations at once
48
+ *
49
+ * @param array $ids
50
+ * @param array $data Column => Value pairs
51
+ * @return int Number of affected rows
52
+ */
53
+ public function updateMultiple($ids, $data)
54
+ {
55
+ $adapter = $this->_getWriteAdapter();
56
+ return $adapter->update($this->getMainTable(), $data, array(
57
+ 'relation_id IN (?)' => $ids
58
+ ));
59
+ }
60
+
61
+ /**
62
+ * Delete relations by ids
63
+ *
64
+ * @param array $ids Relations ids
65
+ * @return int Number of affected rows
66
+ */
67
+ public function deleteMultiple($ids)
68
+ {
69
+ $adapter = $this->_getWriteAdapter();
70
+ return $adapter->delete($this->getMainTable(), array(
71
+ 'relation_id IN (?)' => $ids
72
+ ));
73
+ }
74
+ }
app/code/community/Yavva/Alsoviewed/Model/Resource/Relation/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Model_Resource_Relation_Collection
4
+ extends Yavva_Alsoviewed_Model_Resource_Collection_Abstract
5
+ {
6
+ protected function _construct()
7
+ {
8
+ $this->_init('alsoviewed/relation');
9
+ }
10
+ }
app/code/community/Yavva/Alsoviewed/Model/Session.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Model_Session extends Mage_Core_Model_Session_Abstract
4
+ {
5
+ /**
6
+ * Initialize session namespace
7
+ */
8
+ public function __construct()
9
+ {
10
+ $this->init('alsoviewed');
11
+ }
12
+
13
+ public function addViewedProductId($id)
14
+ {
15
+ $ids = (array) $this->getViewedProductIds();
16
+ $limit = $this->_getViewedLimit();
17
+
18
+ while (count($ids) >= $limit) {
19
+ unset($ids[0]);
20
+ $ids = array_values($ids);
21
+ }
22
+ $ids[] = $id;
23
+
24
+ $this->setViewedProductIds($ids);
25
+ return $this;
26
+ }
27
+
28
+ protected function _getViewedLimit()
29
+ {
30
+ return 10;
31
+ }
32
+ }
app/code/community/Yavva/Alsoviewed/Model/System/Config/Source/ListMode.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Model_System_Config_Source_ListMode
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 'grid', 'label' => Mage::helper('catalog')->__('Grid')),
9
+ array('value' => 'list', 'label' => Mage::helper('catalog')->__('List'))
10
+ );
11
+ }
12
+ }
app/code/community/Yavva/Alsoviewed/controllers/Adminhtml/Alsoviewed/LogController.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Adminhtml_Alsoviewed_LogController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('catalog/alsoviewed_log/index')
9
+ ->_addBreadcrumb(
10
+ Mage::helper('alsoviewed')->__('Also Viewed Products'),
11
+ Mage::helper('alsoviewed')->__('Also Viewed Products')
12
+ );
13
+ return $this;
14
+ }
15
+
16
+ public function indexAction()
17
+ {
18
+ $this->_title($this->__('Also Viewed Log'));
19
+ $this->_initAction();
20
+ $this->renderLayout();
21
+ }
22
+
23
+ public function processAction()
24
+ {
25
+ $log = Mage::getResourceModel('alsoviewed/log');
26
+ $data = $log->getGroupedRelations();
27
+ if ($data) {
28
+ try {
29
+ $result = Mage::getResourceModel('alsoviewed/relation')->updateRelations($data);
30
+ $log->clean();
31
+ $this->_getSession()->addSuccess(
32
+ Mage::helper('adminhtml')->__('Total of %d record(s) have been updated.', $result)
33
+ );
34
+ } catch (Exception $e) {
35
+ $this->_getSession()->addError($e->getMessage());
36
+ }
37
+ }
38
+ $this->_redirect('*/*/index');
39
+ }
40
+
41
+ /**
42
+ * Check the permission to run it
43
+ *
44
+ * @return boolean
45
+ */
46
+ protected function _isAllowed()
47
+ {
48
+ switch ($this->getRequest()->getActionName()) {
49
+ case 'process':
50
+ return Mage::getSingleton('admin/session')->isAllowed('yavva/alsoviewed/alsoviewed_log/process');
51
+ break;
52
+ default:
53
+ return Mage::getSingleton('admin/session')->isAllowed('yavva/alsoviewed/alsoviewed_log');
54
+ break;
55
+ }
56
+ }
57
+ }
app/code/community/Yavva/Alsoviewed/controllers/Adminhtml/Alsoviewed/RelationsController.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yavva_Alsoviewed_Adminhtml_Alsoviewed_RelationsController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('catalog/alsoviewed_relations/index')
9
+ ->_addBreadcrumb(
10
+ $this->__('Also Viewed Products'),
11
+ $this->__('Also Viewed Products')
12
+ );
13
+ return $this;
14
+ }
15
+
16
+ public function indexAction()
17
+ {
18
+ $this->_title($this->__('Also Viewed Relations'));
19
+ $this->_initAction();
20
+ $this->renderLayout();
21
+ }
22
+
23
+ public function editAction()
24
+ {
25
+ $this->_title($this->__('Also Viewed Relations'));
26
+
27
+ $id = $this->getRequest()->getParam('id');
28
+ $model = Mage::getModel('alsoviewed/relation');
29
+ if ($id) {
30
+ $model->load($id);
31
+ if (!$model->getId()) {
32
+ Mage::getSingleton('adminhtml/session')->addError(
33
+ $this->__('This relation no longer exists')
34
+ );
35
+ $this->_redirect('*/*/');
36
+ return;
37
+ }
38
+ } else {
39
+ Mage::getSingleton('adminhtml/session')->addError(
40
+ $this->__('Adding new relation from backend is not supported')
41
+ );
42
+ $this->_redirect('*/*/');
43
+ return;
44
+ }
45
+
46
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
47
+ if (!empty($data)) {
48
+ $model->setData($data);
49
+ }
50
+
51
+ $this->_title($id ? $this->__('Edit Relation') : $this->__('New Relation'));
52
+
53
+ Mage::register('alsoviewed_relation', $model);
54
+ $this->_initAction()
55
+ ->_addBreadcrumb(
56
+ $id ? $this->__('Edit Relation') : $this->__('New Relation'),
57
+ $id ? $this->__('Edit Relation') : $this->__('New Relation')
58
+ );
59
+ $this->renderLayout();
60
+ }
61
+
62
+ public function saveAction()
63
+ {
64
+ if ($data = $this->getRequest()->getPost()) {
65
+ $inverseRelation = isset($data['inverse_relation']);
66
+ unset($data['inverse_relation']);
67
+
68
+ $model = Mage::getModel('alsoviewed/relation');
69
+ $model->addData($data);
70
+ try {
71
+ $model->save();
72
+ if ($inverseRelation) {
73
+ $model->getInverseRelation()
74
+ ->addData(array(
75
+ 'weight' => $data['weight'],
76
+ 'position' => $data['position'],
77
+ 'status' => $data['status']
78
+ ))
79
+ ->save();
80
+ }
81
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('alsoviewed')->__('Relation was successfully saved'));
82
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
83
+ $this->_redirect('*/*/');
84
+ return;
85
+ } catch (Exception $e) {
86
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
87
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
88
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('relation_id')));
89
+ return;
90
+ }
91
+ }
92
+ $this->_redirect('*/*/');
93
+ }
94
+
95
+ public function deleteAction()
96
+ {
97
+ if ($id = $this->getRequest()->getParam('id')) {
98
+ try {
99
+ $model = Mage::getModel('alsoviewed/relation');
100
+ $model->load($id);
101
+ if ($model->getId() && $this->getRequest()->getParam('inverse_relation')) {
102
+ $inverse = $model->getInverseRelation();
103
+ if ($inverse->getId()) {
104
+ $inverse->delete();
105
+ }
106
+ }
107
+ $model->delete();
108
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('alsoviewed')->__('Relation was successfully deleted'));
109
+ $this->_redirect('*/*/');
110
+ return;
111
+ } catch (Exception $e) {
112
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
113
+ $this->_redirect('*/*/edit', array('id' => $id));
114
+ return;
115
+ }
116
+ }
117
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('alsoviewed')->__('Unable to find a relation to delete'));
118
+ $this->_redirect('*/*/');
119
+ }
120
+
121
+ public function massDeleteAction()
122
+ {
123
+ $ids = $this->getRequest()->getParam('relation_id');
124
+ if (!is_array($ids)) {
125
+ $this->_getSession()->addError($this->__('Please select relation(s).'));
126
+ } else {
127
+ if (!empty($ids)) {
128
+ try {
129
+ $count = Mage::getResourceModel('alsoviewed/relation')->deleteMultiple($ids);
130
+ $this->_getSession()->addSuccess(
131
+ $this->__('Total of %d record(s) have been deleted.', $count)
132
+ );
133
+ } catch (Exception $e) {
134
+ $this->_getSession()->addError($e->getMessage());
135
+ }
136
+ }
137
+ }
138
+ $this->_redirect('*/*/index');
139
+ }
140
+
141
+ public function massStatusAction()
142
+ {
143
+ $ids = (array) $this->getRequest()->getParam('relation_id');
144
+ $status = (int) $this->getRequest()->getParam('status');
145
+
146
+ try {
147
+ Mage::getResourceModel('alsoviewed/relation')->updateMultiple($ids, array(
148
+ 'status' => $status
149
+ ));
150
+ $this->_getSession()->addSuccess(
151
+ $this->__('Total of %d record(s) have been updated.', count($ids))
152
+ );
153
+ } catch (Mage_Core_Model_Exception $e) {
154
+ $this->_getSession()->addError($e->getMessage());
155
+ } catch (Mage_Core_Exception $e) {
156
+ $this->_getSession()->addError($e->getMessage());
157
+ } catch (Exception $e) {
158
+ $this->_getSession()
159
+ ->addException($e, $this->__('An error occurred while updating the relation(s) status.'));
160
+ }
161
+ $this->_redirect('*/*/index');
162
+ }
163
+
164
+ /**
165
+ * Check the permission to run it
166
+ *
167
+ * @return boolean
168
+ */
169
+ protected function _isAllowed()
170
+ {
171
+ switch ($this->getRequest()->getActionName()) {
172
+ case 'delete':
173
+ case 'massDelete':
174
+ return Mage::getSingleton('admin/session')->isAllowed('yavva/alsoviewed/alsoviewed_relations/delete');
175
+ break;
176
+ case 'save':
177
+ case 'massStatus':
178
+ return Mage::getSingleton('admin/session')->isAllowed('yavva/alsoviewed/alsoviewed_relations/save');
179
+ break;
180
+ default:
181
+ return Mage::getSingleton('admin/session')->isAllowed('yavva/alsoviewed/alsoviewed_relations');
182
+ break;
183
+ }
184
+ }
185
+ }
app/code/community/Yavva/Alsoviewed/etc/adminhtml.xml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <catalog>
5
+ <children>
6
+ <alsoviewed translate="title" module="alsoviewed">
7
+ <title>Also Viewed Products</title>
8
+ <sort_order>45</sort_order>
9
+ <children>
10
+ <alsoviewed_usage>
11
+ <title>Manage Relations</title>
12
+ <sort_order>10</sort_order>
13
+ <action>adminhtml/alsoviewed_relations/index</action>
14
+ </alsoviewed_usage>
15
+ <alsoviewed_log>
16
+ <title>View Log</title>
17
+ <sort_order>20</sort_order>
18
+ <action>adminhtml/alsoviewed_log/index</action>
19
+ </alsoviewed_log>
20
+ </children>
21
+ </alsoviewed>
22
+ </children>
23
+ </catalog>
24
+ </menu>
25
+ <acl>
26
+ <resources>
27
+ <admin>
28
+ <children>
29
+ <system>
30
+ <children>
31
+ <config>
32
+ <children>
33
+ <alsoviewed translate="title" module="alsoviewed">
34
+ <title>Also Viewed Products Section</title>
35
+ </alsoviewed>
36
+ </children>
37
+ </config>
38
+ </children>
39
+ </system>
40
+ <catalog>
41
+ <children>
42
+ <alsoviewed translate="title" module="alsoviewed">
43
+ <title>Also Viewed Products</title>
44
+ <sort_order>45</sort_order>
45
+ <children>
46
+ <alsoviewed_relations>
47
+ <title>Manage Relations</title>
48
+ <sort_order>10</sort_order>
49
+ <children>
50
+ <save>
51
+ <title>Save Relations</title>
52
+ <sort_order>0</sort_order>
53
+ </save>
54
+ <delete>
55
+ <title>Delete Relations</title>
56
+ <sort_order>0</sort_order>
57
+ </delete>
58
+ </children>
59
+ </alsoviewed_relations>
60
+ <alsoviewed_log>
61
+ <title>View Log</title>
62
+ <sort_order>20</sort_order>
63
+ <children>
64
+ <process>
65
+ <title>Process Log</title>
66
+ <sort_order>0</sort_order>
67
+ </process>
68
+ </children>
69
+ </alsoviewed_log>
70
+ </children>
71
+ </alsoviewed>
72
+ </children>
73
+ </catalog>
74
+ </children>
75
+ </admin>
76
+ </resources>
77
+ </acl>
78
+ </config>
app/code/community/Yavva/Alsoviewed/etc/config.xml ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Yavva_Alsoviewed>
5
+ <version>1.0.0</version>
6
+ </Yavva_Alsoviewed>
7
+ </modules>
8
+
9
+ <global>
10
+ <blocks>
11
+ <alsoviewed>
12
+ <class>Yavva_Alsoviewed_Block</class>
13
+ </alsoviewed>
14
+ </blocks>
15
+ <helpers>
16
+ <alsoviewed>
17
+ <class>Yavva_Alsoviewed_Helper</class>
18
+ </alsoviewed>
19
+ </helpers>
20
+ <models>
21
+ <alsoviewed>
22
+ <class>Yavva_Alsoviewed_Model</class>
23
+ <resourceModel>alsoviewed_resource</resourceModel>
24
+ </alsoviewed>
25
+ <alsoviewed_resource>
26
+ <class>Yavva_Alsoviewed_Model_Resource</class>
27
+ <entities>
28
+ <log>
29
+ <table>yavva_alsoviewed_log</table>
30
+ </log>
31
+ <relation>
32
+ <table>yavva_alsoviewed_relation</table>
33
+ </relation>
34
+ </entities>
35
+ </alsoviewed_resource>
36
+ </models>
37
+ <resources>
38
+ <yavva_alsoviewed_setup>
39
+ <setup>
40
+ <module>Yavva_Alsoviewed</module>
41
+ </setup>
42
+ </yavva_alsoviewed_setup>
43
+ </resources>
44
+ </global>
45
+
46
+ <frontend>
47
+ <translate>
48
+ <modules>
49
+ <Yavva_Alsoviewed>
50
+ <files>
51
+ <default>Yavva_Alsoviewed.csv</default>
52
+ </files>
53
+ </Yavva_Alsoviewed>
54
+ </modules>
55
+ </translate>
56
+ <layout>
57
+ <updates>
58
+ <alsoviewed>
59
+ <file>yavva/alsoviewed.xml</file>
60
+ </alsoviewed>
61
+ </updates>
62
+ </layout>
63
+ <events>
64
+ <controller_action_predispatch_catalog_product_view>
65
+ <observers>
66
+ <alsoviewed>
67
+ <class>alsoviewed/observer</class>
68
+ <method>catalogProductView</method>
69
+ </alsoviewed>
70
+ </observers>
71
+ </controller_action_predispatch_catalog_product_view>
72
+ </events>
73
+ </frontend>
74
+
75
+ <admin>
76
+ <routers>
77
+ <adminhtml>
78
+ <args>
79
+ <modules>
80
+ <alsoviewed after="Mage_Adminhtml">Yavva_Alsoviewed_Adminhtml</alsoviewed>
81
+ </modules>
82
+ </args>
83
+ </adminhtml>
84
+ </routers>
85
+ </admin>
86
+
87
+ <adminhtml>
88
+ <translate>
89
+ <modules>
90
+ <Yavva_Alsoviewed>
91
+ <files>
92
+ <default>Yavva_Alsoviewed.csv</default>
93
+ </files>
94
+ </Yavva_Alsoviewed>
95
+ </modules>
96
+ </translate>
97
+ <layout>
98
+ <updates>
99
+ <alsoviewed>
100
+ <file>yavva/alsoviewed.xml</file>
101
+ </alsoviewed>
102
+ </updates>
103
+ </layout>
104
+ </adminhtml>
105
+
106
+ <crontab>
107
+ <jobs>
108
+ <alsoviewed_process_log>
109
+ <schedule>
110
+ <cron_expr>*/15 * * * *</cron_expr>
111
+ </schedule>
112
+ <run>
113
+ <model>alsoviewed/observer::processLog</model>
114
+ </run>
115
+ </alsoviewed_process_log>
116
+ </jobs>
117
+ </crontab>
118
+
119
+ <default>
120
+ <alsoviewed>
121
+ <content>
122
+ <enabled>0</enabled>
123
+ <mode>grid</mode>
124
+ <products_count>4</products_count>
125
+ <column_count>4</column_count>
126
+ <image_width>170</image_width>
127
+ <image_height>170</image_height>
128
+ </content>
129
+ <left>
130
+ <enabled>0</enabled>
131
+ <mode>list</mode>
132
+ <products_count>4</products_count>
133
+ <column_count>3</column_count>
134
+ <image_width>170</image_width>
135
+ <image_height>170</image_height>
136
+ </left>
137
+ <right>
138
+ <enabled>0</enabled>
139
+ <mode>list</mode>
140
+ <products_count>4</products_count>
141
+ <column_count>3</column_count>
142
+ <image_width>170</image_width>
143
+ <image_height>170</image_height>
144
+ </right>
145
+ </alsoviewed>
146
+ </default>
147
+ </config>
app/code/community/Yavva/Alsoviewed/etc/system.xml ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <alsoviewed translate="label" module="alsoviewed">
5
+ <label>Also Viewed Products</label>
6
+ <tab>catalog</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>45</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <content>
14
+ <label>Product additional information</label>
15
+ <sort_order>10</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
+ <fields>
20
+ <enabled translate="label" module="core">
21
+ <label>Enabled</label>
22
+ <frontend_type>select</frontend_type>
23
+ <source_model>adminhtml/system_config_source_yesno</source_model>
24
+ <sort_order>10</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ </enabled>
29
+ <mode translate="label" module="catalog">
30
+ <label>List Mode</label>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>alsoviewed/system_config_source_listMode</source_model>
33
+ <sort_order>20</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </mode>
38
+ <products_count translate="label" module="catalog">
39
+ <label>Display Product Count</label>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>30</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </products_count>
46
+ <column_count>
47
+ <label>Columns count</label>
48
+ <frontend_type>text</frontend_type>
49
+ <depends>
50
+ <mode>
51
+ <value>grid</value>
52
+ </mode>
53
+ </depends>
54
+ <sort_order>40</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </column_count>
59
+ <image_width translate="label" module="catalog">
60
+ <label>Image width</label>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>50</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ </image_width>
67
+ <image_height translate="label" module="catalog">
68
+ <label>Image height</label>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>60</sort_order>
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
+ </image_height>
75
+ </fields>
76
+ </content>
77
+ <left>
78
+ <label>Left Column</label>
79
+ <sort_order>20</sort_order>
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
+ <fields>
84
+ <enabled translate="label" module="core">
85
+ <label>Enabled</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>adminhtml/system_config_source_yesno</source_model>
88
+ <sort_order>10</sort_order>
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
+ </enabled>
93
+ <mode translate="label" module="catalog">
94
+ <label>List Mode</label>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>alsoviewed/system_config_source_listMode</source_model>
97
+ <sort_order>20</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ </mode>
102
+ <products_count translate="label" module="catalog">
103
+ <label>Display Product Count</label>
104
+ <frontend_type>text</frontend_type>
105
+ <sort_order>30</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ </products_count>
110
+ <column_count>
111
+ <label>Columns count</label>
112
+ <frontend_type>text</frontend_type>
113
+ <depends>
114
+ <mode>
115
+ <value>grid</value>
116
+ </mode>
117
+ </depends>
118
+ <sort_order>40</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ </column_count>
123
+ <image_width translate="label" module="catalog">
124
+ <label>Image width</label>
125
+ <frontend_type>text</frontend_type>
126
+ <sort_order>50</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ </image_width>
131
+ <image_height translate="label" module="catalog">
132
+ <label>Image height</label>
133
+ <frontend_type>text</frontend_type>
134
+ <sort_order>60</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ </image_height>
139
+ </fields>
140
+ </left>
141
+ <right>
142
+ <label>Right Column</label>
143
+ <sort_order>30</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>1</show_in_store>
147
+ <fields>
148
+ <enabled translate="label" module="core">
149
+ <label>Enabled</label>
150
+ <frontend_type>select</frontend_type>
151
+ <source_model>adminhtml/system_config_source_yesno</source_model>
152
+ <sort_order>10</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>1</show_in_store>
156
+ </enabled>
157
+ <mode translate="label" module="catalog">
158
+ <label>List Mode</label>
159
+ <frontend_type>select</frontend_type>
160
+ <source_model>alsoviewed/system_config_source_listMode</source_model>
161
+ <sort_order>20</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ </mode>
166
+ <products_count translate="label" module="catalog">
167
+ <label>Display Product Count</label>
168
+ <frontend_type>text</frontend_type>
169
+ <sort_order>30</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>1</show_in_website>
172
+ <show_in_store>1</show_in_store>
173
+ </products_count>
174
+ <column_count>
175
+ <label>Columns count</label>
176
+ <frontend_type>text</frontend_type>
177
+ <depends>
178
+ <mode>
179
+ <value>grid</value>
180
+ </mode>
181
+ </depends>
182
+ <sort_order>40</sort_order>
183
+ <show_in_default>1</show_in_default>
184
+ <show_in_website>1</show_in_website>
185
+ <show_in_store>1</show_in_store>
186
+ </column_count>
187
+ <image_width translate="label" module="catalog">
188
+ <label>Image width</label>
189
+ <frontend_type>text</frontend_type>
190
+ <sort_order>50</sort_order>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>1</show_in_website>
193
+ <show_in_store>1</show_in_store>
194
+ </image_width>
195
+ <image_height translate="label" module="catalog">
196
+ <label>Image height</label>
197
+ <frontend_type>text</frontend_type>
198
+ <sort_order>60</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
+ </image_height>
203
+ </fields>
204
+ </right>
205
+ </groups>
206
+ </alsoviewed>
207
+ </sections>
208
+ </config>
app/code/community/Yavva/Alsoviewed/sql/yavva_alsoviewed_setup/install-1.0.0.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $table = $installer->getConnection()
7
+ ->newTable($installer->getTable('alsoviewed/relation'))
8
+ ->addColumn('relation_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
9
+ 'identity' => true,
10
+ 'unsigned' => true,
11
+ 'nullable' => false,
12
+ 'primary' => true,
13
+ ), 'Relation ID')
14
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
15
+ 'unsigned' => true,
16
+ 'nullable' => false,
17
+ ), 'Product ID')
18
+ ->addColumn('related_product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
19
+ 'unsigned' => true,
20
+ 'nullable' => false,
21
+ ), 'Related Product ID')
22
+ ->addColumn('weight', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
23
+ 'unsigned' => true,
24
+ 'nullable' => false,
25
+ 'default' => '0',
26
+ ), 'Relation Weight')
27
+ ->addColumn('position', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
28
+ 'nullable' => false,
29
+ 'default' => '50',
30
+ ), 'Custom Sort Order Parameter')
31
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
32
+ 'unsigned' => true,
33
+ 'nullable' => false,
34
+ 'default' => '1',
35
+ ), 'Status')
36
+ ->addIndex(
37
+ $installer->getIdxName(
38
+ 'alsoviewed/relation',
39
+ array('product_id', 'related_product_id'),
40
+ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
41
+ ),
42
+ array('product_id', 'related_product_id'),
43
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
44
+ ->addIndex(
45
+ $installer->getIdxName('alsoviewed/relation', array('product_id')),
46
+ array('product_id'))
47
+ ->addIndex(
48
+ $installer->getIdxName('alsoviewed/relation', array('weight', 'position')),
49
+ array('weight', 'position'))
50
+ ->addIndex(
51
+ $installer->getIdxName('alsoviewed/relation', array('status')),
52
+ array('status'))
53
+ ->addForeignKey($installer->getFkName('alsoviewed/relation', 'product_id', 'catalog/product', 'entity_id'),
54
+ 'product_id', $installer->getTable('catalog/product'), 'entity_id',
55
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
56
+ ->addForeignKey($installer->getFkName('alsoviewed/relation', 'related_product_id', 'catalog/product', 'entity_id'),
57
+ 'related_product_id', $installer->getTable('catalog/product'), 'entity_id',
58
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
59
+ ->setComment('Alsoviewed Relations Table');
60
+ $installer->getConnection()->createTable($table);
61
+
62
+ $table = $installer->getConnection()
63
+ ->newTable($installer->getTable('alsoviewed/log'))
64
+ ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array(
65
+ 'identity' => true,
66
+ 'unsigned' => true,
67
+ 'nullable' => false,
68
+ 'primary' => true,
69
+ ), 'Entity ID')
70
+ ->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
71
+ 'unsigned' => true,
72
+ 'nullable' => false,
73
+ ), 'Product ID')
74
+ ->addColumn('related_product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
75
+ 'unsigned' => true,
76
+ 'nullable' => false,
77
+ ), 'Related Product ID')
78
+ ->setComment('Alsoviewed Relations Log Table');
79
+ $installer->getConnection()->createTable($table);
80
+
81
+ $installer->endSetup();
app/design/adminhtml/base/default/layout/yavva/alsoviewed.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_alsoviewed_relations_index>
4
+ <reference name="content">
5
+ <block type="alsoviewed/adminhtml_relations" name="alsoviewed_relations"/>
6
+ </reference>
7
+ </adminhtml_alsoviewed_relations_index>
8
+
9
+ <adminhtml_alsoviewed_relations_new>
10
+ <update handle="adminhtml_alsoviewed_relations_edit" />
11
+ </adminhtml_alsoviewed_relations_new>
12
+
13
+ <adminhtml_alsoviewed_relations_edit>
14
+ <reference name="content">
15
+ <block type="alsoviewed/adminhtml_relations_edit" name="alsoviewed_relations_edit"/>
16
+ </reference>
17
+ </adminhtml_alsoviewed_relations_edit>
18
+
19
+ <adminhtml_alsoviewed_log_index>
20
+ <reference name="content">
21
+ <block type="alsoviewed/adminhtml_log" name="alsoviewed_log"/>
22
+ </reference>
23
+ </adminhtml_alsoviewed_log_index>
24
+ </layout>
app/design/frontend/base/default/layout/yavva/alsoviewed.xml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addItem"><type>skin_css</type><name>yavva/alsoviewed/css/alsoviewed.css</name></action>
6
+ </reference>
7
+ </default>
8
+
9
+ <catalog_product_view>
10
+ <reference name="product.info.additional">
11
+ <block type="core/template" name="alsoviewed.content.wrapper" before="-">
12
+ <action method="setTemplate" ifconfig="alsoviewed/content/enabled">
13
+ <template>yavva/alsoviewed/wrapper/content.phtml</template>
14
+ </action>
15
+ <block type="alsoviewed/products" name="alsoviewed.list" template="yavva/alsoviewed/products.phtml">
16
+ <action method="addDataFromConfig"><path>alsoviewed/content</path></action>
17
+ </block>
18
+ </block>
19
+ </reference>
20
+ <reference name="left">
21
+ <block type="core/template" name="alsoviewed.left.wrapper" before="-">
22
+ <action method="setTemplate" ifconfig="alsoviewed/left/enabled">
23
+ <template>yavva/alsoviewed/wrapper/sidebar.phtml</template>
24
+ </action>
25
+ <block type="alsoviewed/products" name="alsoviewed.list" template="yavva/alsoviewed/products.phtml">
26
+ <action method="addDataFromConfig"><path>alsoviewed/left</path></action>
27
+ </block>
28
+ </block>
29
+ </reference>
30
+ <reference name="right">
31
+ <block type="core/template" name="alsoviewed.right.wrapper" before="-">
32
+ <action method="setTemplate" ifconfig="alsoviewed/right/enabled">
33
+ <template>yavva/alsoviewed/wrapper/sidebar.phtml</template>
34
+ </action>
35
+ <block type="alsoviewed/products" name="alsoviewed.list" template="yavva/alsoviewed/products.phtml">
36
+ <action method="addDataFromConfig"><path>alsoviewed/right</path></action>
37
+ </block>
38
+ </block>
39
+ </reference>
40
+ </catalog_product_view>
41
+
42
+ <!-- Move to the RWD tabs -->
43
+ <!-- Copy and uncomment the code to your theme local.xml -->
44
+ <!--
45
+ <catalog_product_view>
46
+ <reference name="product.info.additional">
47
+ <action method="unsetChild"><name>alsoviewed.content.wrapper</name></action>
48
+ </reference>
49
+ <reference name="product.info">
50
+ <action method="append"><name>alsoviewed.content.wrapper</name></action>
51
+ </reference>
52
+ <reference name="alsoviewed.content.wrapper">
53
+ <action method="addToParentGroup"><group>detailed_info</group></action>
54
+ <action method="setTitle" translate="value"><value>People who viewed this product also viewed</value></action>
55
+ </reference>
56
+ </catalog_product_view>
57
+ -->
58
+
59
+ <!-- Move to the Argento tabs -->
60
+ <!-- Copy and uncomment the code to your theme custom.xml -->
61
+ <!--
62
+ <catalog_product_view>
63
+ <reference name="product.info.additional">
64
+ <action method="unsetChild"><name>alsoviewed.content.wrapper</name></action>
65
+ </reference>
66
+ <reference name="product.info.tabs">
67
+ <action method="addTab" translate="title" module="alsoviewed" ifconfig="alsoviewed/content/enabled">
68
+ <alias>alsoviewed.content.wrapper</alias>
69
+ <title><![CDATA[You may also like]]></title>
70
+ </action>
71
+ </reference>
72
+ </catalog_product_view>
73
+ -->
74
+ </layout>
app/design/frontend/base/default/template/yavva/alsoviewed/products.phtml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_productCollection = $this->getProductCollection();
3
+ $_helper = $this->helper('catalog/output');
4
+
5
+ $_imageWidth = $this->getImageWidth();
6
+ $_imageHeight = $this->getImageHeight();
7
+ ?>
8
+
9
+ <?php if($this->getMode()=='list'): ?>
10
+ <?php $_iterator = 0; ?>
11
+ <ol class="products-list" id="products-list">
12
+ <?php foreach ($_productCollection as $_product): ?>
13
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
14
+ <?php // Product Image ?>
15
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
16
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imageWidth, $_imageHeight); ?>"
17
+ srcset="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imageWidth * 2, $_imageHeight * 2); ?> 2x"
18
+ alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>"
19
+ />
20
+ </a>
21
+ <?php // Product description ?>
22
+ <div class="product-shop">
23
+ <div class="f-fix">
24
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
25
+ <h4 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h4>
26
+ <?php if($_product->getRatingSummary()): ?>
27
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
28
+ <?php endif; ?>
29
+ <?php echo $this->getPriceHtml($_product, true) ?>
30
+ <?php if($_product->isSaleable()): ?>
31
+ <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
32
+ <?php else: ?>
33
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
34
+ <?php endif; ?>
35
+ <div class="desc std">
36
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
37
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
38
+ </div>
39
+ <ul class="add-to-links">
40
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
41
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
42
+ <?php endif; ?>
43
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
44
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
45
+ <?php endif; ?>
46
+ </ul>
47
+ </div>
48
+ </div>
49
+ </li>
50
+ <?php endforeach; ?>
51
+ </ol>
52
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
53
+
54
+ <?php else: ?>
55
+
56
+ <?php // Grid Mode ?>
57
+
58
+ <?php $_collectionSize = $_productCollection->count() ?>
59
+ <?php $_columnCount = $this->getColumnCount(); ?>
60
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
61
+ <?php if ($i++%$_columnCount==0): ?>
62
+ <ul class="products-grid cols-<?php echo $_columnCount ?>">
63
+ <?php endif ?>
64
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
65
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
66
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imageWidth, $_imageHeight); ?>"
67
+ srcset="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imageWidth * 2, $_imageHeight * 2); ?> 2x"
68
+ alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>"
69
+ />
70
+ </a>
71
+ <h4 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h4>
72
+ <?php if($_product->getRatingSummary()): ?>
73
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
74
+ <?php endif; ?>
75
+ <?php echo $this->getPriceHtml($_product, true) ?>
76
+ <div class="actions">
77
+ <?php if($_product->isSaleable()): ?>
78
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
79
+ <?php else: ?>
80
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
81
+ <?php endif; ?>
82
+ <ul class="add-to-links">
83
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
84
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
85
+ <?php endif; ?>
86
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
87
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
88
+ <?php endif; ?>
89
+ </ul>
90
+ </div>
91
+ </li>
92
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
93
+ </ul>
94
+ <?php endif ?>
95
+ <?php endforeach ?>
96
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
97
+ <?php endif; ?>
app/design/frontend/base/default/template/yavva/alsoviewed/wrapper/content.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_list = $this->getChild('alsoviewed.list');
3
+ if (!$_list) :
4
+ return;
5
+ endif;
6
+
7
+ $_productCollection = $_list->getProductCollection();
8
+ if (!$_productCollection->getSize()) :
9
+ return;
10
+ endif;
11
+ ?>
12
+
13
+ <div class="box-collateral alsoviewed">
14
+ <h2><?php echo $this->__("People who viewed this product also viewed"); ?></h2>
15
+ <?php echo $this->getChildHtml('alsoviewed.list') ?>
16
+ </div>
app/design/frontend/base/default/template/yavva/alsoviewed/wrapper/sidebar.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_list = $this->getChild('alsoviewed.list');
3
+ if (!$_list) :
4
+ return;
5
+ endif;
6
+
7
+ $_productCollection = $_list->getProductCollection();
8
+ if (!$_productCollection->getSize()) :
9
+ return;
10
+ endif;
11
+ ?>
12
+
13
+ <div class="block alsoviewed">
14
+ <div class="block-title"><strong><span><?php echo $this->__("You may also like"); ?></span></strong></div>
15
+ <div class="block-content">
16
+ <?php echo $this->getChildHtml('alsoviewed.list') ?>
17
+ </div>
18
+ </div>
app/etc/modules/Yavva_Alsoviewed.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Yavva_Alsoviewed>
4
+ <active>true</active>
5
+ <codePool>community</codePool>
6
+ <depends>
7
+ <Mage_Catalog/>
8
+ </depends>
9
+ </Yavva_Alsoviewed>
10
+ </modules>
11
+ </config>
app/locale/en_US/Yavva_Alsoviewed.csv ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Also Viewed Products","Also Viewed Products"
2
+ "Also Viewed Products Section","Also Viewed Products Section"
3
+ "Product additional information","Product additional information"
4
+ "Columns count","Columns count"
5
+ "People who viewed this product also viewed","People who viewed this product also viewed"
6
+ "You may also like","You may also like"
7
+ "Manage Relations","Manage Relations"
8
+ "View Log","View Log"
9
+ "Save Relations","Save Relations"
10
+ "Delete Relations","Delete Relations"
11
+ "Process Log","Process Log"
12
+ "Related Product","Related Product"
13
+ "Please select relation(s).","Please select relation(s)."
14
+ "Also Viewed Relations","Also Viewed Relations"
15
+ "Also Viewed Log","Also Viewed Log"
16
+ "Image width","Image width"
17
+ "Image height","Image height"
18
+ "Relation","Relation"
19
+ "Position is used to sort products manually","Position is used to sort products manually"
20
+ "Weight is automatically increased by module. It is highly recommended to not to change it, to see the actual popular relations","Weight is automatically increased by module. It is highly recommended to not to change it, to see the actual popular relations"
21
+ "Apply the same values to the inverse relation","Apply the same values to the inverse relation"
22
+ "Delete with inverse relation","Delete with inverse relation"
23
+ "New Relation","New Relation"
24
+ "Edit Relation '%s'","Edit Relation '%s'"
25
+ "This relation no longer exists","This relation no longer exists"
26
+ "Edit Relation","Edit Relation"
27
+ "Relation was successfully saved","Relation was successfully saved"
28
+ "Relation was successfully deleted","Relation was successfully deleted"
29
+ "Unable to find a relation to delete","Unable to find a relation to delete"
package.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>alsoviewed</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Free magento module, that shows products viewed by customers who viewed this product.</summary>
10
+ <description>Module uses automatically collected anonymous browsing history to predict the product alternatives.&#xD;
11
+ &#xD;
12
+ Module key features are:&#xD;
13
+ * 100% Free and open source&#xD;
14
+ * High Perfomance&#xD;
15
+ * Simple and clean design&#xD;
16
+ * Responsive out of the box&#xD;
17
+ </description>
18
+ <notes>Initial release</notes>
19
+ <authors><author><name>Vova Yatsyuk</name><user>VovaYatsyuk</user><email>vova.yatsyuk@gmail.com</email></author></authors>
20
+ <date>2015-01-04</date>
21
+ <time>20:22:24</time>
22
+ <contents><target name="magecommunity"><dir name="Yavva"><dir name="Alsoviewed"><dir name="Block"><dir name="Adminhtml"><dir name="Log"><file name="Grid.php" hash="6661435fdb8e525775adf990a90d11c4"/></dir><file name="Log.php" hash="cb3cca5ff29b80044e7943d376dc5993"/><dir name="Relations"><dir name="Edit"><file name="Form.php" hash="0ad20532cb04c4c850fe1398598e6588"/></dir><file name="Edit.php" hash="1afce837cf4bd29beb1cc8f38d4065b6"/><file name="Grid.php" hash="e10da78030dbfb1ecbb32f6df82ddfa1"/></dir><file name="Relations.php" hash="6561a0acaacc1bc8e5046be59da888b6"/></dir><file name="Products.php" hash="f68a609061f807a4cb7bc6715e009dba"/></dir><dir name="Helper"><file name="Data.php" hash="d8057e1e4731c53a6b1e72a626ce9ac3"/></dir><dir name="Model"><file name="Observer.php" hash="05ad4c1cbc6fe8cf8863836a34d97951"/><file name="Relation.php" hash="506d2fa53e2e342030bdfb976a2f0e00"/><dir name="Resource"><dir name="Collection"><file name="Abstract.php" hash="6d996d6b7643f1b3cc3c0db3d5440011"/></dir><dir name="Log"><file name="Collection.php" hash="790509f4a4e74cc007adae600c0d8a1b"/></dir><file name="Log.php" hash="d79d4a97ba3303dfa3e042ec34c2e0e3"/><dir name="Relation"><file name="Collection.php" hash="be05b1351c8703f1157b6f552612ffa8"/></dir><file name="Relation.php" hash="c154166a4318331e47b755749965a045"/></dir><file name="Session.php" hash="9ba3b43dec9458cc13cb6c6e7efbef05"/><dir name="System"><dir name="Config"><dir name="Source"><file name="ListMode.php" hash="d3480dc016dc0ff9e2e23ab210cf9756"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Alsoviewed"><file name="LogController.php" hash="99f28be50bbf022986c8da75a092d267"/><file name="RelationsController.php" hash="de5a35329a09477a79ec65c57a4280ca"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ff26af98f8e1eef8d902eca84da6d3aa"/><file name="config.xml" hash="dea6bedc82185fa083b16859047fdb2f"/><file name="system.xml" hash="c0eed7ac29a29ff2a9da28ecd8254c12"/></dir><dir name="sql"><dir name="yavva_alsoviewed_setup"><file name="install-1.0.0.php" hash="8ed81d46895731990b7c2066bfcc353d"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><dir name="yavva"><file name="alsoviewed.xml" hash="53473beb4db371b273400ae8fa223a32"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="yavva"><file name="alsoviewed.xml" hash="a4e876bb9b161f0e8d9e99606c3b7e3c"/></dir></dir><dir name="template"><dir name="yavva"><dir name="alsoviewed"><file name="products.phtml" hash="d55af4e92a7fbe929c10b81a804ddffe"/><dir name="wrapper"><file name="content.phtml" hash="8be64ccce70e0d00b2f0ef7cc4e6b61e"/><file name="sidebar.phtml" hash="476a0bc03c19e400fcdd0837545646be"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Yavva_Alsoviewed.xml" hash="4eedb69f4c1fc39a1e4170694a19c3f8"/></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Yavva_Alsoviewed.csv" hash="7045cf15cb0ee5505ff5e914de938b1e"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="yavva"><dir name="alsoviewed"><dir name="css"><file name="alsoviewed.css" hash="d31aebd6e1a30e3620669f1013519336"/></dir><file name=".DS_Store" hash="47b2bb12e2c4c4275ce2349d6b4570d0"/></dir></dir></dir></dir></dir></target></contents>
23
+ <compatible/>
24
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
25
+ </package>
skin/frontend/base/default/yavva/alsoviewed/.DS_Store ADDED
Binary file
skin/frontend/base/default/yavva/alsoviewed/css/alsoviewed.css ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* reset cms page std styles */
2
+ .std .alsoviewed ul,
3
+ .std .alsoviewed ol { margin: 0; padding: 0; list-style: none; }
4
+ .std .alsoviewed .add-to-links { margin: 5px 0 0; }
5
+ .std .alsoviewed .add-to-links li { margin: 0; }
6
+ .std .alsoviewed .price-box p { margin: 0; }
7
+
8
+ .alsoviewed .block-title { color: #0A263C; font-size: 14px; font-weight: bold; }
9
+ .col-main .alsoviewed { margin: 0 0 0.7em; }
10
+ .alsoviewed img { max-width: 100%; height: auto; }
11
+ .alsoviewed .products-grid { position: static; background: none; width: auto; }
12
+ .alsoviewed .products-grid .actions { position: static; }
13
+
14
+ /* multicolumns mode */
15
+ .alsoviewed .products-grid li.item {
16
+ padding: 7px 1%;
17
+ margin: 0 1% 7px;
18
+ clear: none;
19
+ box-sizing: border-box;
20
+ }
21
+ .alsoviewed .products-grid.cols-1 li.item { width: 100%; }
22
+ .alsoviewed .products-grid.cols-2 li.item { width: 48%; }
23
+ .alsoviewed .products-grid.cols-3 li.item { width: 31.3%; }
24
+ .alsoviewed .products-grid.cols-4 li.item { width: 23%; }
25
+ .alsoviewed .products-grid.cols-5 li.item { width: 18%; }
26
+ .alsoviewed .products-grid.cols-6 li.item { width: 14.6%; }
27
+ .alsoviewed .products-grid li.item:last-child { margin: 0 1% 7px; } /* rwd fix */
28
+
29
+ .alsoviewed .products-list .product-image { max-width: 135px; }
30
+ .alsoviewed .products-list .product-shop { margin-left: 150px; float: none; width: auto; padding-left: 0; }
31
+ .alsoviewed .products-list .product-shop .product-name { float: none; }
32
+ .product-view .alsoviewed .add-to-links { margin-right: 0; float: none; }
33
+ .product-view .alsoviewed .add-to-links li { float: none; }
34
+ .product-view .alsoviewed .add-to-links a { border: none; }
35
+
36
+ /* Sidebar */
37
+ .sidebar .alsoviewed .product-name { font-size: 1em; }
38
+ .sidebar .alsoviewed .products-grid li.item { padding-top: 4px; padding-bottom: 4px; margin-bottom: 5px; }
39
+ .sidebar .alsoviewed .products-grid li.item:last-child { margin-bottom: 5px; } /* rwd fix */
40
+ .sidebar .alsoviewed .products-grid .product-image { margin: 0; width: auto; height: auto; }
41
+ .sidebar .alsoviewed .products-grid .product-name,
42
+ .sidebar .alsoviewed .products-grid .price-box,
43
+ .sidebar .alsoviewed .products-grid .actions { display: none; }
44
+ .sidebar .alsoviewed .products-list li.item { padding: 5px; }
45
+ .sidebar .alsoviewed .products-list .add-to-links li { float: none; display: block; }
46
+ .sidebar .alsoviewed .products-list .product-image { max-width: 30%; height: auto; margin: 0; }
47
+ .sidebar .alsoviewed .products-list .product-shop { margin: 0 0 0 32%; }
48
+ .sidebar .alsoviewed .products-list .btn-cart,
49
+ .sidebar .alsoviewed .products-list .desc,
50
+ .sidebar .alsoviewed .products-list .add-to-links .separator { display: none; }
51
+
52
+ .alsoviewed .block-content { zoom: 1; }
53
+ .alsoviewed .block-content:after { content: '.'; display: block; clear: both; visibility: hidden; height: 0; font-size: 0; }
54
+
55
+ @media (max-width: 767px) {
56
+ /* Three columns instead of six */
57
+ .alsoviewed .products-grid.cols-6 li.item { width: 31.3%; }
58
+ .alsoviewed .products-grid.cols-6 li.item:nth-of-type(4n) { clear: left; }
59
+ }
60
+
61
+ @media (max-width: 480px) {
62
+ .alsoviewed .products-grid.cols-6 li.item:nth-of-type(4n) { clear: none; }
63
+ /* Two columns for small screen */
64
+ .alsoviewed .products-grid li.item { width: 48% !important; padding-left: 2%; padding-right: 2%; }
65
+ .alsoviewed .products-grid.cols-1 li.item { width: 100% !important; margin-left: 0; margin-right: 0; }
66
+ /* clear: left for every third li */
67
+ .alsoviewed .products-grid.cols-2 li.item:nth-of-type(2n+1),
68
+ .alsoviewed .products-grid.cols-4 li.item:nth-of-type(2n+1),
69
+ .alsoviewed .products-grid.cols-6 li.item:nth-of-type(2n+1),
70
+ /* clear: left for every third li inside every third .easycatalog-grid */
71
+ .alsoviewed .products-grid.cols-3:nth-of-type(2n+1) li.item:nth-of-type(2n+1),
72
+ .alsoviewed .products-grid.cols-5:nth-of-type(2n+1) li.item:nth-of-type(2n+1),
73
+ /* clear: left for every second li inside every second .easycatalog-grid */
74
+ .alsoviewed .products-grid.cols-3:nth-of-type(2n) li.item:nth-of-type(2n),
75
+ .alsoviewed .products-grid.cols-5:nth-of-type(2n) li.item:nth-of-type(2n) { clear: left; }
76
+ .alsoviewed .products-grid.cols-3:after,
77
+ .alsoviewed .products-grid.cols-5:after { content: ''; clear: none; }
78
+ }