Speroteck_SelectedProductsBlock - Version 0.1.0

Version Notes

First release

Download this release

Release Info

Developer Speroteck Team
Extension Speroteck_SelectedProductsBlock
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Speroteck/SelectedProductsBlock/Block/List.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Selected products
5
+ *
6
+ * @category Speroteck
7
+ * @package Speroteck_SelectedProductsBlock
8
+ * @licence
9
+ *
10
+ */
11
+
12
+ /**
13
+ * Class Speroteck_SelectedProductsBlock_Block_List
14
+ *
15
+ * @method integer getProductsLimit()
16
+ * @method string getSelectedProducts()
17
+ * @method string getBlockName()
18
+ * @method string getUniqueId()
19
+ *
20
+ */
21
+ class Speroteck_SelectedProductsBlock_Block_List extends Mage_Catalog_Block_Product_List
22
+ implements Mage_Widget_Block_Interface
23
+ {
24
+ /**
25
+ * Return products collection
26
+ *
27
+ * @return Mage_Catalog_Model_Resource_Product_Collection
28
+ *
29
+ */
30
+ public function getProductCollection()
31
+ {
32
+ $skuList = $this->_filterSkuList($this->getSelectedProducts());
33
+
34
+ /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
35
+ $collection = Mage::getModel('catalog/product')->getCollection();
36
+ $collection
37
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
38
+ ->addMinimalPrice()
39
+ ->addFinalPrice()
40
+ ->addTaxPercents();
41
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
42
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
43
+
44
+ $collection->getSelect()->limit($this->getProductsLimit());
45
+ $collection->getSelect()->where('e.sku IN(?)', $skuList);
46
+
47
+ return $collection;
48
+ }
49
+
50
+ /**
51
+ *
52
+ * @param string $skuList
53
+ *
54
+ * @return Array
55
+ */
56
+ protected function _filterSkuList($skuList)
57
+ {
58
+ $result = array();
59
+ foreach (explode(',', $skuList) as $sku) {
60
+ $result[] = trim($sku);
61
+ }
62
+
63
+ return $result;
64
+ }
65
+ }
app/code/community/Speroteck/SelectedProductsBlock/Helper/Data.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Selected products
5
+ *
6
+ * @category Speroteck
7
+ * @package Speroteck_SelectedProductsBlock
8
+ * @licence
9
+ *
10
+ */
11
+
12
+ /**
13
+ * Helper
14
+ *
15
+ * @category Speroteck
16
+ * @package Speroteck_SelectedProductsBlock
17
+ */
18
+ class Speroteck_SelectedProductsBlock_Helper_Data extends Mage_Core_Helper_Abstract
19
+ {
20
+ }
app/code/community/Speroteck/SelectedProductsBlock/etc/config.xml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Selected products
5
+ *
6
+ * @category Speroteck
7
+ * @package Speroteck_SelectedProductsBlock
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Speroteck_SelectedProductsBlock>
13
+ <version>0.1.0</version>
14
+ </Speroteck_SelectedProductsBlock>
15
+ </modules>
16
+ <global>
17
+ <helpers>
18
+ <speroteck_selectedproductsblock>
19
+ <class>Speroteck_SelectedProductsBlock_Helper</class>
20
+ </speroteck_selectedproductsblock>
21
+ </helpers>
22
+ <blocks>
23
+ <speroteck_selectedproductsblock>
24
+ <class>Speroteck_SelectedProductsBlock_Block</class>
25
+ </speroteck_selectedproductsblock>
26
+ </blocks>
27
+ </global>
28
+ <frontend>
29
+ <layout>
30
+ <updates>
31
+ <speroteck_selectedproductsblock>
32
+ <file>speroteck/selectedproductsblock.xml</file>
33
+ </speroteck_selectedproductsblock>
34
+ </updates>
35
+ </layout>
36
+ </frontend>
37
+ </config>
app/code/community/Speroteck/SelectedProductsBlock/etc/widget.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Selected products
5
+ *
6
+ * @category Speroteck
7
+ * @package Speroteck_SelectedProductsBlock
8
+ */
9
+ -->
10
+ <widgets>
11
+ <Speroteck_SelectedProductsBlock type="speroteck_selectedproductsblock/list" module="speroteck_selectedproductsblock">
12
+ <name>Display selected products</name>
13
+ <description>Display list of selected products</description>
14
+ <parameters>
15
+ <block_name translate="label">
16
+ <label>Block Name</label>
17
+ <type>text</type>
18
+ <required>1</required>
19
+ <visible >1</visible>
20
+ </block_name>
21
+ <template translate="label">
22
+ <label>Frontend Template</label>
23
+ <visible>1</visible>
24
+ <required>1</required>
25
+ <type>select</type>
26
+ <values>
27
+ <grid translate="label">
28
+ <value>speroteck/selectedproductsblock/default.phtml</value>
29
+ <label>Default template</label>
30
+ </grid>
31
+ </values>
32
+ </template>
33
+ <products_limit translate="label">
34
+ <label>Products Limit</label>
35
+ <type>text</type>
36
+ <required>1</required>
37
+ <visible >1</visible>
38
+ <value>4</value>
39
+ </products_limit>
40
+ <selected_products>
41
+ <label>Product sku's</label>
42
+ <description>Product sku's separated by comma</description>
43
+ <type>textarea</type>
44
+ <required>1</required>
45
+ <visible >1</visible>
46
+ </selected_products>
47
+ </parameters>
48
+ </Speroteck_SelectedProductsBlock>
49
+ </widgets>
app/design/frontend/base/default/layout/speroteck/selectedproductsblock.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Selected products
5
+ *
6
+ * @category Speroteck
7
+ * @package Speroteck_SelectedProductsBlock
8
+ */
9
+ -->
10
+ <layout>
11
+ <default>
12
+ <reference name="head">
13
+ <action method="addItem"><type>js_css</type><name>speroteck/selectedproductsblock/css/style.css</name><params/></action>
14
+ </reference>
15
+ </default>
16
+ </layout>
app/design/frontend/base/default/template/speroteck/selectedproductsblock/default.phtml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Selected products
4
+ *
5
+ * @category Speroteck
6
+ * @package Speroteck_SelectedProductsBlock
7
+ */
8
+
9
+ /** @var $this Speroteck_SelectedProductsBlock_Block_List */
10
+
11
+ $products = $this->getProductCollection();
12
+ ?>
13
+ <?php if ($products && $products->getSize()): ?>
14
+ <div class="block block-products selected-products">
15
+ <div class="block-title">
16
+ <strong><span><?php echo $this->getBlockName() ?></span></strong>
17
+ </div>
18
+ <div class="block-content">
19
+ <div class="products-block">
20
+ <?php foreach ($products->getItems() as $product): ?>
21
+ <?php /** @var $product Mage_Catalog_Model_Product */ ?>
22
+ <div class="item">
23
+ <a class="product-image"
24
+ href="<?php echo $product->getProductUrl() ?>"
25
+ title="<?php echo $this->stripTags($product->getName(), null, true) ?>">
26
+ <img
27
+ src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(120) ?>"
28
+ alt="<?php echo $this->stripTags($product->getName(), null, true) ?>" />
29
+ </a>
30
+
31
+ <div class="product-details">
32
+ <p class="product-name">
33
+ <a href="<?php echo $product->getProductUrl() ?>"
34
+ title="<?php echo $this->stripTags($product->getName(), null, true) ?>)">
35
+ <?php echo $this->helper('catalog/output')->productAttribute($product, $product->getName(), 'name') ?>
36
+ </a>
37
+ </p>
38
+ <?php if ($product->getIsSalable()): ?>
39
+ <div class="product-price">
40
+ <?php echo $this->getPriceHtml($product, true) ?>
41
+ </div>
42
+ <button type="button"
43
+ title="<?php echo $this->__('Add to Cart') ?>"
44
+ class="button btn-cart"
45
+ onclick="setLocation('<?php echo $this->getAddToCartUrl($product) ?>')">
46
+ <span><span><?php echo $this->__('Add to Cart') ?></span></span>
47
+ </button>
48
+ <?php endif; ?>
49
+ </div>
50
+ </div>
51
+ <?php endforeach; ?>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ <?php endif; ?>
56
+
57
+
58
+
59
+
60
+
app/etc/modules/Speroteck_SelectedProductsBlock.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Selected products
5
+ *
6
+ * @category Speroteck
7
+ * @package Speroteck_SelectedProductsBlock
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Speroteck_SelectedProductsBlock>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ </Speroteck_SelectedProductsBlock>
16
+ </modules>
17
+ </config>
js/speroteck/selectedproductsblock/css/style.css ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .selected-products .item {
2
+ float: left;
3
+ padding-left: 20px;
4
+ padding-top: 20px;
5
+ padding-bottom: 20px;
6
+ width: 140px;
7
+ }
8
+ .selected-products .product-name {
9
+ word-break: normal;
10
+ }
11
+
12
+ .selected-products .product-details {
13
+ margin-top: 5px;
14
+ }
15
+ .selected-products .price-box p {
16
+ margin-bottom: 0;
17
+ }
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Speroteck_SelectedProductsBlock</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License v. 3.0 (OSL-3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Widget to display list of selected products</summary>
10
+ <description>Widget to display list of selected products. It allows to configure: block name, list of products (by sku), limit of products to display, template</description>
11
+ <notes>First release</notes>
12
+ <authors><author><name>Speroteck Team</name><user>Speroteck</user><email>dev@speroteck.com</email></author></authors>
13
+ <date>2014-03-25</date>
14
+ <time>11:14:52</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Speroteck_SelectedProductsBlock.xml" hash="ea16d3ccac518bcd461b3db29921c0e5"/></dir></target><target name="magecommunity"><dir name="Speroteck"><dir name="SelectedProductsBlock"><dir name="Block"><file name="List.php" hash="adf9914faeb371e2032f0d44fc6a8ef4"/></dir><dir name="Helper"><file name="Data.php" hash="bad466bc4178594ce13ae9503f9cfdff"/></dir><dir name="etc"><file name="config.xml" hash="84374ae88564e5d5ef79a40a27d02201"/><file name="widget.xml" hash="0277f8e181fdaa01502a9905302bf4d0"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="speroteck"><file name="selectedproductsblock.xml" hash="aeda99675f0774a1b6eadd9fc4f03364"/></dir></dir><dir name="template"><dir name="speroteck"><dir name="selectedproductsblock"><file name="default.phtml" hash="7ceda98a435dadd932959b5780cc45f1"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="speroteck"><dir name="selectedproductsblock"><dir name="css"><file name="style.css" hash="fc077d1b11bcbe2e9046e7c66d5f26e8"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><extension><name>Core</name><min/><max/></extension></required></dependencies>
18
+ </package>