Quarticon_Quartic - Version 0.1.0

Version Notes

The extension integrates your store with Quartic platform.

Download this release

Release Info

Developer QuarticON
Extension Quarticon_Quartic
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (43) hide show
  1. app/code/community/Quarticon/Quartic/Block/Admin/Urls.php +18 -0
  2. app/code/community/Quarticon/Quartic/Block/Admin/Urls/Grid.php +55 -0
  3. app/code/community/Quarticon/Quartic/Block/Box.php +20 -0
  4. app/code/community/Quarticon/Quartic/Block/Frame/Cart.php +34 -0
  5. app/code/community/Quarticon/Quartic/Block/Frame/Category.php +55 -0
  6. app/code/community/Quarticon/Quartic/Block/Frame/Home.php +20 -0
  7. app/code/community/Quarticon/Quartic/Block/Frame/Product.php +24 -0
  8. app/code/community/Quarticon/Quartic/Block/Getter/Order.php +40 -0
  9. app/code/community/Quarticon/Quartic/Block/Getter/Product.php +20 -0
  10. app/code/community/Quarticon/Quartic/Block/Products.php +56 -0
  11. app/code/community/Quarticon/Quartic/Block/Script.php +12 -0
  12. app/code/community/Quarticon/Quartic/Helper/Data.php +41 -0
  13. app/code/community/Quarticon/Quartic/Model/Attribute.php +45 -0
  14. app/code/community/Quarticon/Quartic/Model/Config.php +63 -0
  15. app/code/community/Quarticon/Quartic/Model/Order.php +84 -0
  16. app/code/community/Quarticon/Quartic/Model/Product.php +277 -0
  17. app/code/community/Quarticon/Quartic/controllers/Adminhtml/IndexController.php +16 -0
  18. app/code/community/Quarticon/Quartic/controllers/FeedController.php +122 -0
  19. app/code/community/Quarticon/Quartic/controllers/FrameController.php +14 -0
  20. app/code/community/Quarticon/Quartic/etc/adminhtml.xml +14 -0
  21. app/code/community/Quarticon/Quartic/etc/config.xml +133 -0
  22. app/code/community/Quarticon/Quartic/etc/system.xml +161 -0
  23. app/code/community/Quarticon/Quartic/sql/quartic_setup/mysql4-install-0.1.0.php +9 -0
  24. app/design/adminhtml/default/default/layout/quartic.xml +15 -0
  25. app/design/adminhtml/default/default/template/quartic/urls.phtml +10 -0
  26. app/design/frontend/base/default/layout/quartic.xml +41 -0
  27. app/design/frontend/base/default/template/quartic/frame/cart.phtml +13 -0
  28. app/design/frontend/base/default/template/quartic/frame/category.phtml +13 -0
  29. app/design/frontend/base/default/template/quartic/frame/home.phtml +12 -0
  30. app/design/frontend/base/default/template/quartic/frame/product.phtml +16 -0
  31. app/design/frontend/base/default/template/quartic/getter/order.phtml +17 -0
  32. app/design/frontend/base/default/template/quartic/getter/product.phtml +10 -0
  33. app/design/frontend/base/default/template/quartic/products.phtml +90 -0
  34. app/design/frontend/base/default/template/quartic/products/slt_cart.phtml +1 -0
  35. app/design/frontend/base/default/template/quartic/products/slt_category.phtml +1 -0
  36. app/design/frontend/base/default/template/quartic/products/slt_home.phtml +1 -0
  37. app/design/frontend/base/default/template/quartic/products/slt_product.phtml +1 -0
  38. app/design/frontend/base/default/template/quartic/script.phtml +27 -0
  39. app/etc/modules/Quarticon_Quartic.xml +9 -0
  40. app/locale/pl_PL/Quarticon_Quartic.csv +23 -0
  41. package.xml +18 -0
  42. skin/adminhtml/default/default/images/quarticon-icon.png +0 -0
  43. skin/adminhtml/default/default/quartic.css +7 -0
app/code/community/Quarticon/Quartic/Block/Admin/Urls.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Admin_Urls extends Mage_Adminhtml_Block_Widget_Container {
3
+
4
+ public function __construct() {
5
+ parent::__construct();
6
+ $this->setTemplate('quartic/urls.phtml');
7
+ }
8
+
9
+ protected function _prepareLayout() {
10
+ $this->setChild('grid', $this->getLayout()->createBlock('quartic/admin_urls_grid', 'quartic_urls_grid'));
11
+ return parent::_prepareLayout();
12
+ }
13
+
14
+ public function getGridHtml() {
15
+ return $this->getChildHtml('grid');
16
+ }
17
+
18
+ }
app/code/community/Quarticon/Quartic/Block/Admin/Urls/Grid.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Admin_Urls_Grid extends Mage_Adminhtml_Block_Widget_Grid {
3
+
4
+ public function __construct() {
5
+ parent::__construct();
6
+ $this->setId('quartic_urls_grid');
7
+ $this->setDefaultSort('name');
8
+ $this->setDefaultDir('asc');
9
+ }
10
+
11
+ protected function getConfig() {
12
+ return Mage::getModel('quartic/config');
13
+ }
14
+
15
+ protected function _prepareCollection(){
16
+ $collection = Mage::getModel('core/store')->getCollection();
17
+ foreach ($collection as &$item) {
18
+ $item->setQuarticProductsUrl($item->getUrl('quartic/feed/products', array('hash' => $this->getConfig()->getHash())));
19
+ $item->setQuarticOrdersUrl($item->getUrl('quartic/feed/orders', array('hash' => $this->getConfig()->getHash())));
20
+ }
21
+ $this->setCollection($collection);
22
+ return parent::_prepareCollection();
23
+ }
24
+
25
+ protected function _prepareColumns() {
26
+ $this->addColumn('store_id', array(
27
+ 'header' => Mage::helper('quartic')->__('Store ID'),
28
+ 'align' => 'right',
29
+ 'width' => '50px',
30
+ 'index' => 'store_id',
31
+ ));
32
+ $this->addColumn('name', array(
33
+ 'header' => Mage::helper('quartic')->__('Store Name'),
34
+ 'align' => 'left',
35
+ 'width' => '200px',
36
+ 'index' => 'name',
37
+ ));
38
+ $this->addColumn('quartic_products_url', array(
39
+ 'header' => Mage::helper('quartic')->__('Quartic Products URL'),
40
+ 'align' => 'left',
41
+ 'index' => 'quartic_products_url',
42
+ ));
43
+ $this->addColumn('quartic_orders_url', array(
44
+ 'header' => Mage::helper('quartic')->__('Quartic Orders URL'),
45
+ 'align' => 'left',
46
+ 'index' => 'quartic_orders_url',
47
+ ));
48
+ return parent::_prepareColumns();
49
+ }
50
+
51
+ public function getRowUrl($row) {
52
+ //return $row->getCeneoUrl();
53
+ }
54
+
55
+ }
app/code/community/Quarticon/Quartic/Block/Box.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Box extends Mage_Core_Block_Template {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getModel('quartic/config');
6
+ }
7
+
8
+ public function isActive() {
9
+ return $this->getConfig()->isActive();
10
+ }
11
+
12
+ public function getCustomer() {
13
+ return $this->getConfig()->getCustomer();
14
+ }
15
+
16
+ public function getUser() {
17
+ return $this->getConfig()->getSession()->getCustomer()->getId();
18
+ }
19
+
20
+ }
app/code/community/Quarticon/Quartic/Block/Frame/Cart.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Frame_Cart extends Mage_Checkout_Block_Cart {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getModel('quartic/config');
6
+ }
7
+
8
+ public function isActive() {
9
+ return $this->getConfig()->isActive() && $this->getConfig()->isFrameEnabled('cart');
10
+ }
11
+
12
+ public function getCustomer() {
13
+ return $this->getConfig()->getCustomer();
14
+ }
15
+
16
+ public function getUser() {
17
+ return $this->getConfig()->getSession()->getCustomer()->getId();
18
+ }
19
+
20
+ public function getProducts() {
21
+ $items = $this->getQuote()->getAllItems();
22
+ $products = array();
23
+ foreach ($items as $item) {
24
+ if (!$item->getParentItemId()) {
25
+ $product = Mage::helper('quartic')->getProduct($item);
26
+ if (!in_array($product, $products)) {
27
+ $products[] = $product;
28
+ }
29
+ }
30
+ }
31
+ return implode(',', $products);
32
+ }
33
+
34
+ }
app/code/community/Quarticon/Quartic/Block/Frame/Category.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Frame_Category extends Mage_Catalog_Block_Category_View {
3
+
4
+ protected function _construct() {
5
+ if ($this->getConfig()->shouldUseProductFrameInCategory()) {
6
+ $this->setTemplate('quartic/frame/product.phtml');
7
+ } else {
8
+ $this->setTemplate('quartic/frame/category.phtml');
9
+ }
10
+ }
11
+
12
+ protected function getConfig() {
13
+ return Mage::getModel('quartic/config');
14
+ }
15
+
16
+ public function isActive() {
17
+ return $this->getConfig()->isActive() && $this->getConfig()->isFrameEnabled('category');
18
+ }
19
+
20
+ public function getCustomer() {
21
+ return $this->getConfig()->getCustomer();
22
+ }
23
+
24
+ public function getUser() {
25
+ return $this->getConfig()->getSession()->getCustomer()->getId();
26
+ }
27
+
28
+ /**
29
+ * Gets SKU/id of random product in the current category.
30
+ *
31
+ * @return string
32
+ */
33
+ public function getProductId() {
34
+ return Mage::helper('quartic')->getProduct($this->getRandomProduct());
35
+ }
36
+
37
+ /**
38
+ * Gets random product from current category
39
+ *
40
+ * @return Mage_Catalog_Model_Product
41
+ */
42
+ public function getRandomProduct() {
43
+ $category = Mage::getModel('catalog/category')->load($this->getCurrentCategory()->getId());
44
+ $count = $category->getProductCount();
45
+ if ($count) {
46
+ $randomIndex = rand(0, $count - 1);
47
+ $productCollection = $category->getProductCollection()
48
+ ->setPageSize(1)
49
+ ->setCurPage($randomIndex);
50
+ return $productCollection->getFirstItem();
51
+ }
52
+ return null;
53
+ }
54
+
55
+ }
app/code/community/Quarticon/Quartic/Block/Frame/Home.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Frame_Home extends Mage_Core_Block_Template {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getModel('quartic/config');
6
+ }
7
+
8
+ public function isActive() {
9
+ return $this->getConfig()->isActive() && $this->getConfig()->isFrameEnabled('homepage');
10
+ }
11
+
12
+ public function getCustomer() {
13
+ return $this->getConfig()->getCustomer();
14
+ }
15
+
16
+ public function getUser() {
17
+ return $this->getConfig()->getSession()->getCustomer()->getId();
18
+ }
19
+
20
+ }
app/code/community/Quarticon/Quartic/Block/Frame/Product.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Frame_Product extends Mage_Catalog_Block_Product_View {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getModel('quartic/config');
6
+ }
7
+
8
+ public function isActive() {
9
+ return $this->getConfig()->isActive() && $this->getConfig()->isFrameEnabled('product');
10
+ }
11
+
12
+ public function getCustomer() {
13
+ return $this->getConfig()->getCustomer();
14
+ }
15
+
16
+ public function getUser() {
17
+ return $this->getConfig()->getSession()->getCustomer()->getId();
18
+ }
19
+
20
+ public function getProductId() {
21
+ return Mage::helper('quartic')->getProduct($this->getProduct());
22
+ }
23
+
24
+ }
app/code/community/Quarticon/Quartic/Block/Getter/Order.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Getter_Order extends Mage_Core_Block_Template {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getModel('quartic/config');
6
+ }
7
+
8
+ public function isActive() {
9
+ return $this->getConfig()->isActive();
10
+ }
11
+
12
+ public function getCustomer() {
13
+ return $this->getConfig()->getCustomer();
14
+ }
15
+
16
+ public function getUser() {
17
+ return $this->getConfig()->getSession()->getCustomer()->getId();
18
+ }
19
+
20
+ public function getOrder() {
21
+ return Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
22
+ }
23
+
24
+ public function getProducts() {
25
+ $items = $this->getOrder()->getAllItems();
26
+ $products = array();
27
+ foreach ($items as $item) {
28
+ if (!$item->getParentItemId()) {
29
+ $product = Mage::helper('quartic')->getProduct($item);
30
+ $products[] = array(
31
+ 'product' => $product,
32
+ 'price' => $item->getPriceInclTax(),
33
+ 'quantity' => (int)$item->getQtyOrdered()
34
+ );
35
+ }
36
+ }
37
+ return $products;
38
+ }
39
+
40
+ }
app/code/community/Quarticon/Quartic/Block/Getter/Product.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Getter_Product extends Mage_Catalog_Block_Product_View {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getModel('quartic/config');
6
+ }
7
+
8
+ public function isActive() {
9
+ return $this->getConfig()->isActive();
10
+ }
11
+
12
+ public function getCustomer() {
13
+ return $this->getConfig()->getCustomer();
14
+ }
15
+
16
+ public function getUser() {
17
+ return $this->getConfig()->getSession()->getCustomer()->getId();
18
+ }
19
+
20
+ }
app/code/community/Quarticon/Quartic/Block/Products.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Products extends Mage_Catalog_Block_Product_List {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getSingleton('quartic/config');
6
+ }
7
+
8
+ public function getLoadedProductCollection() {
9
+
10
+ $use_sku = $this->getConfig()->isUsingSkuEnabled(); /* SKU or ID */
11
+ $request = $this->getRequest();
12
+ $collection = Mage::getModel('catalog/product')->getCollection()
13
+ ->addAttributeToSelect('*');
14
+
15
+ if ($use_sku) {
16
+ $sku_array = $request->getParam('sku');
17
+ $collection->addFieldToFilter('sku', array('in' => $sku_array));
18
+ } else {
19
+ $id_array = $request->getParam('sku');
20
+ $collection->addFieldToFilter('entity_id', array('in' => $id_array));
21
+ }
22
+ if ($this->getConfig()->showOnlyInStock()) {
23
+ $collection->joinField(
24
+ 'qty',
25
+ 'cataloginventory/stock_item',
26
+ 'qty',
27
+ 'product_id=entity_id',
28
+ '{{table}}.stock_id=1',
29
+ 'left'
30
+ )
31
+ ->addAttributeToFilter('qty', array('gt' => 0));
32
+ }
33
+ return $collection;
34
+ }
35
+
36
+ public function getQuarticUrl($product) {
37
+ $use_sku = $this->getConfig()->isUsingSkuEnabled(); /* SKU or ID */
38
+ if ($use_sku) {
39
+ $skuid = $product->getSku();
40
+ }
41
+ else {
42
+ $skuid = $product->getId();
43
+ }
44
+ $request = $this->getRequest();
45
+ $skuid_array = $request->getParam('sku');
46
+ $url_array = $request->getParam('url');
47
+ $i = array_search($skuid, $skuid_array);
48
+ $quartic_url = $url_array[$i] ? $url_array[$i] : $product->getProductUrl();
49
+ return $quartic_url;
50
+ }
51
+
52
+ public function getQuarticAddToCartUrl($product) {
53
+ return $this->getAddToCartUrl($product);
54
+ }
55
+
56
+ }
app/code/community/Quarticon/Quartic/Block/Script.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Block_Script extends Mage_Core_Block_Template {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getModel('quartic/config');
6
+ }
7
+
8
+ public function isActive() {
9
+ return $this->getConfig()->isActive();
10
+ }
11
+
12
+ }
app/code/community/Quarticon/Quartic/Helper/Data.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Helper_Data extends Mage_Core_Helper_Abstract {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getModel('quartic/config');
6
+ }
7
+
8
+ /**
9
+ * Gets product SKU or ID based on module configuration.
10
+ *
11
+ * @param array|object $item
12
+ * @return string
13
+ */
14
+ public function getProduct($item) {
15
+ if ($item) {
16
+ $use_sku = $this->getConfig()->isUsingSkuEnabled();
17
+ $product = $use_sku ? (is_array($item) ? ($item['real_sku'] ? $item['real_sku'] : $item['sku']) : $this->_getRealSku($item)) : (is_array($item) ? (isset($item['product_id']) ? $item['product_id'] : $item['id']) : ($item->getProductId() ? $item->getProductId() : $item->getId()));
18
+ return $product;
19
+ }
20
+ return false;
21
+ }
22
+
23
+ /**
24
+ * Gets real SKU of item, ie. parent item's SKU
25
+ *
26
+ * @param array|object $item
27
+ * @return string
28
+ */
29
+ protected function _getRealSku($item) {
30
+ if ($item->getProductType() === 'configurable') {
31
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
32
+ $sku = $product->getSku();
33
+ $product->clearInstance();
34
+ unset($product);
35
+ return $sku;
36
+ } else {
37
+ return $item->getSku();
38
+ }
39
+ }
40
+
41
+ }
app/code/community/Quarticon/Quartic/Model/Attribute.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Model_Attribute extends Mage_Core_Model_Abstract {
3
+
4
+ protected function _construct() {
5
+ $this->_init('quartic/attribute');
6
+ }
7
+
8
+ public function toOptionArray() {
9
+ $attributes_collection = Mage::getModel('catalog/entity_attribute')->getCollection()
10
+ ->addFieldToFilter('entity_type_id', $this->_getEntityTypeId());
11
+ $res = array();
12
+ foreach ($attributes_collection as $attribute) {
13
+ $res[$attribute->getAttributeCode()] = array(
14
+ 'label' => $attribute->getAttributeCode(),
15
+ 'value' => $attribute->getAttributeCode()
16
+ );
17
+ }
18
+ ksort($res);
19
+ return array_merge(array(array('label' => '', 'value' => '')), $res);
20
+ }
21
+
22
+ public function getOptionsByCode($code) {
23
+ $attr = Mage::getModel('eav/config')->getAttribute('catalog_product', $code);
24
+ $options = $attr->getSource()->getAllOptions();
25
+ $res = array();
26
+ foreach ($options as $option) {
27
+ $res[$option['value']] = $option['label'];
28
+ }
29
+ unset($res['']);
30
+ return $res;
31
+ }
32
+
33
+ /**
34
+ * Gets catalog product EAV entity type id.
35
+ *
36
+ * @return string
37
+ */
38
+ protected function _getEntityTypeId() {
39
+ $collection = Mage::getModel('eav/entity_type')->getCollection()
40
+ ->addFieldToFilter('entity_type_code', 'catalog_product');
41
+ $item = $collection->getFirstItem();
42
+ return $item->getId();
43
+ }
44
+
45
+ }
app/code/community/Quarticon/Quartic/Model/Config.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Model_Config extends Mage_Core_Model_Config {
3
+
4
+ public function getSession() {
5
+ return Mage::getSingleton('customer/session');
6
+ }
7
+
8
+ public function saveHash() {
9
+ $hash = md5(microtime());
10
+ Mage::getModel('core/config')->saveConfig('quartic/config/hash', $hash, 'default', 0);
11
+ }
12
+
13
+ public function getHash($store_id = null) {
14
+ return Mage::getStoreConfig('quartic/config/hash', $store_id);
15
+ }
16
+
17
+ public function getAuthorMapping($store_id = null) {
18
+ return Mage::getStoreConfig('quartic/config/author', $store_id);
19
+ }
20
+
21
+ public function isActive($store_id = null) {
22
+ return (bool)Mage::getStoreConfig('quartic/config/active', $store_id);
23
+ }
24
+
25
+ public function isFrameEnabled($frame, $store_id = null) {
26
+ return (bool)Mage::getStoreConfig('quartic/frames/'.$frame, $store_id);
27
+ }
28
+
29
+ public function getCustomer($store_id = null) {
30
+ return Mage::getStoreConfig('quartic/config/customer', $store_id);
31
+ }
32
+
33
+ public function isUsingSkuEnabled($store_id = null) {
34
+ return (bool)Mage::getStoreConfig('quartic/config/use_sku', $store_id);
35
+ }
36
+
37
+ public function showOnlyInStock($store_id = null) {
38
+ return (bool)Mage::getStoreConfig('quartic/config/only_in_stock', $store_id);
39
+ }
40
+
41
+ public function addThumbs($store_id = null) {
42
+ return (bool)Mage::getStoreConfig('quartic/config/add_thumbs', $store_id);
43
+ }
44
+
45
+ public function showDisabledProducts($store_id = null) {
46
+ return (bool)Mage::getStoreConfig('quartic/config/show_disabled_products', $store_id);
47
+ }
48
+
49
+ public function shouldUseProductFrameInCategory($store_id = null) {
50
+ return (bool)Mage::getStoreConfig('quartic/frames/category_use_product_frame', $store_id);
51
+ }
52
+
53
+ /**
54
+ * Gets minimum quantity for which a product status should be set to 1 in XML feed.
55
+ *
56
+ * @param int $store_id
57
+ * @return int
58
+ */
59
+ public function getMinQty($store_id = null) {
60
+ return (int) Mage::getStoreConfig('quartic/config/min_qty', $store_id);
61
+ }
62
+
63
+ }
app/code/community/Quarticon/Quartic/Model/Order.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Quarticon_Quartic_Model_Order extends Mage_Core_Model_Abstract {
4
+
5
+ const ITERATION_STEP = 1000;
6
+
7
+ protected $_db = null;
8
+ protected $_orders_table = null;
9
+ protected $_order_items_table = null;
10
+ protected $_products_table = null;
11
+ protected $_store_id = null;
12
+
13
+ protected function getConfig() {
14
+ return Mage::getModel('quartic/config');
15
+ }
16
+
17
+ protected function _getStoreId() {
18
+ if (!$this->_store_id) {
19
+ $store = Mage::app()->getStore();
20
+ $this->_store_id = $store->getStoreId();
21
+ }
22
+ return $this->_store_id;
23
+ }
24
+
25
+ protected function _getDB() {
26
+ if (!$this->_db) {
27
+ $this->_db = Mage::getSingleton('core/resource')->getConnection('core_read');
28
+ }
29
+ return $this->_db;
30
+ }
31
+
32
+ protected function _getOrdersTable() {
33
+ if (!$this->_orders_table) {
34
+ $this->_orders_table = $this->_getDB()->getTableName('sales_flat_order');
35
+ }
36
+ return $this->_orders_table;
37
+ }
38
+
39
+ protected function _getOrderItemsTable() {
40
+ if (!$this->_order_items_table) {
41
+ $this->_order_items_table = $this->_getDB()->getTableName('sales_flat_order_item');
42
+ }
43
+ return $this->_order_items_table;
44
+ }
45
+
46
+ protected function _getProductsTable() {
47
+ if (!$this->_products_table) {
48
+ $this->_products_table = $this->_getDB()->getTableName('catalog_product_entity');
49
+ }
50
+ return $this->_products_table;
51
+ }
52
+
53
+ public function getCollectionCount() {
54
+ $sql = 'select count(*) as c from ' . $this->_getOrdersTable() . ' as o ' .
55
+ 'left join ' . $this->_getOrderItemsTable() . ' as i on(i.order_id = o.entity_id and i.parent_item_id is null) ' .
56
+ 'where o.store_id = ' . $this->_getStoreId();
57
+
58
+ $q = $this->_getDB()->fetchRow($sql);
59
+ return $q['c'];
60
+ }
61
+
62
+ public function getAll($page_num = 1, $page_size = 10) {
63
+ $sql = 'select o.increment_id, o.created_at, o.customer_id, i.product_id, i.sku, i.qty_ordered, i.price_incl_tax, i.product_type, p.sku as real_sku from ' . $this->_getOrdersTable() . ' as o ' .
64
+ 'left join ' . $this->_getOrderItemsTable() . ' as i on(i.order_id = o.entity_id and i.parent_item_id is null) ' .
65
+ 'left join ' . $this->_getProductsTable() . ' as p on(i.product_id = p.entity_id) ' .
66
+ 'where o.store_id = ' . $this->_getStoreId() . ' order by i.item_id limit ' . (($page_num - 1) * $page_size) . ', ' . $page_size;
67
+ $collection = $this->_getDB()->fetchAll($sql);
68
+ foreach ($collection as $order) {
69
+ $o = array(
70
+ 'id' => $order['increment_id'],
71
+ 'timestamp' => $order['created_at'],
72
+ 'user' => $order['customer_id'] ? $order['customer_id'] : '',
73
+ 'product' => Mage::helper('quartic')->getProduct($order),
74
+ 'quantity' => $order['qty_ordered'] * 1,
75
+ 'price' => $order['price_incl_tax']
76
+ );
77
+ $orders[] = $o;
78
+ unset($o);
79
+ }
80
+ unset($collection);
81
+ return $orders;
82
+ }
83
+
84
+ }
app/code/community/Quarticon/Quartic/Model/Product.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // TODO: $product->getFinalPrice() zapycha pamięć.
4
+
5
+ class Quarticon_Quartic_Model_Product extends Mage_Core_Model_Abstract {
6
+
7
+ const ITERATION_STEP = 25;
8
+
9
+ protected $default_attribute_set_id = null;
10
+ protected $_categories = array();
11
+ protected $_imagesUrl = null;
12
+ protected $_minQty = false;
13
+
14
+ protected function getConfig() {
15
+ return Mage::getModel('quartic/config');
16
+ }
17
+
18
+ protected function _getCollection() {
19
+ $_product = Mage::getModel('catalog/product');
20
+ $store = Mage::app()->getStore();
21
+ $collection = $_product->getCollection()
22
+ ->addStoreFilter($store->getStoreId());
23
+ return $this->_addDisableFilters($collection);;
24
+ }
25
+
26
+ protected function _addDisableFilters($collection) {
27
+ if (!$this->getConfig()->showDisabledProducts()) {
28
+ $collection->addFieldToFilter('status', array('eq' => 1));
29
+ }
30
+ return $collection;
31
+ }
32
+
33
+ /**
34
+ * If "min_qty" config value is greater than zero, qty is added to the products collection.
35
+ */
36
+ protected function _addQtyField($collection) {
37
+ if ($this->getConfig()->getMinQty()) {
38
+ $collection->joinField(
39
+ 'qty',
40
+ 'cataloginventory/stock_item',
41
+ 'qty',
42
+ 'product_id=entity_id',
43
+ null,
44
+ 'left'
45
+ );
46
+ }
47
+ return $collection;
48
+ }
49
+
50
+ public function getCollectionCount() {
51
+ return $this->_getCollection()->getSize();
52
+ }
53
+
54
+ protected function _getFinalCollection($page_num = 1, $page_size = 10, $product_id = false) {
55
+ $collection = $this->_getCollection()
56
+ ->setPage($page_num, $page_size)
57
+ ->addAttributeToSelect('price')
58
+ ->addAttributeToSelect('special_price')
59
+ ->addAttributeToSelect('name')
60
+ ->addAttributeToSelect('category_ids')
61
+ ->addAttributeToSelect('visibility')
62
+ ->addAttributeToSelect('status')
63
+ ->addAttributeToSelect('sku');
64
+ foreach ($additional_attributes as $code => $options) {
65
+ $collection->addAttributeToSelect($code);
66
+ }
67
+ if ($product_id) {
68
+ $collection->addFieldToFilter('entity_id', $product_id);
69
+ }
70
+ $collection = $this->_addAdditionalAttributes($collection);
71
+ $collection = $this->_addQtyField($collection);
72
+ return $collection;
73
+ }
74
+
75
+ public function getAll($page_num = 1, $page_size = 10) {
76
+ $author_mapping = $this->getConfig()->getAuthorMapping();
77
+ $_attribute = Mage::getModel('quartic/attribute');
78
+ $additional_attributes = array();
79
+ if (!empty($author_mapping)) {
80
+ $additional_attributes[$author_mapping] = $_attribute->getOptionsByCode($author_mapping);
81
+ }
82
+ $collection = $this->_getFinalCollection($page_num, $page_size, false);
83
+ $offers = array();
84
+ $media = $this->getConfig()->addThumbs() ? $this->getMediaData($collection) : array();
85
+ if (!empty($media)) {
86
+ $this->_imagesUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product';
87
+ }
88
+ $product_items = $collection->getItems();
89
+ foreach ($product_items as $id => $product) {
90
+ $images = isset($media[$product->getId()]) ? $media[$product->getId()] : array();
91
+ $configurable_id = $this->getConfigurableIdByChildId($product->getId());
92
+ if ($configurable_id !== 0) {
93
+ // Do not show configurable product children
94
+ continue;
95
+ }
96
+ $offers[] = $this->handleProductToGetOffer($product, $images, $additional_attributes);
97
+ }
98
+ $collection->clear();
99
+ unset($collection);
100
+ unset($media);
101
+ return $offers;
102
+ }
103
+
104
+ protected function _getSingleProduct($product_id) {
105
+ $collection = $this->_getFinalCollection(1, 1, $product_id);
106
+ $product = $collection->getFirstItem();
107
+ if ($product->getId()) {
108
+ return $product;
109
+ }
110
+ return false;
111
+ }
112
+
113
+ /*
114
+ * Method that prepares one product to be appended to $offers table
115
+ *
116
+ * $product - product to be processed
117
+ * $images - object with media data
118
+ * $additional_attributes - definitions of additional product attributes
119
+ * $rewrite_url - URL that rewrites standard product URL. If null then no rewrite is executed
120
+ */
121
+ protected function handleProductToGetOffer($product, $images, $additional_attributes = array()) {
122
+ $category_ids = array_slice($product->getCategoryIds(), 0, 6);
123
+ $offer = array(
124
+ 'id' => Mage::helper('quartic')->getProduct($product),
125
+ 'title' => $product->getName(),
126
+ 'price' => $this->getFinalPriceIncludingTax($product),
127
+ 'link' => $product->getProductUrl(),
128
+ 'categories' => $this->getCategories($category_ids),
129
+ 'status' => $this->_getStatus($product)
130
+ );
131
+ $special_price = $product->getSpecialPrice();
132
+ if ($special_price) {
133
+ $offer['old_price'] = $this->getPriceIncludingTax($product);
134
+ }
135
+ foreach ($images as $image) {
136
+ $disabled = (bool) (($image['disabled'] !== null) ? $image['disabled'] : $image['disabled_default']);
137
+ if (!$disabled) {
138
+ $offer['thumb'] = $this->_imagesUrl . $image['file'];
139
+ break;
140
+ }
141
+ }
142
+ unset($images);
143
+ if (!empty($author_mapping)) {
144
+ $value = $product->getData($author_mapping);
145
+ if (!empty($value)) {
146
+ $options = $additional_attributes[$author_mapping];
147
+ if (!empty($options)) {
148
+ $offer['author'] = $options[$value];
149
+ } else {
150
+ $offer['author'] = $value;
151
+ }
152
+ }
153
+ unset($value);
154
+ }
155
+ $product->clearInstance();
156
+ unset($product);
157
+ return $offer;
158
+ }
159
+
160
+ public function getMediaData($_productCollection) {
161
+ if (is_array($_productCollection)) {
162
+ $all_ids = $_productCollection;
163
+ } else {
164
+ $all_ids = $_productCollection->getAllIds();
165
+ }
166
+ $_mediaGalleryByProductId = array();
167
+ if (!empty($all_ids)) {
168
+ $_mediaGalleryAttributeId = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'media_gallery')->getAttributeId();
169
+ $_read = Mage::getSingleton('core/resource')->getConnection('catalog_read');
170
+ $_mediaGalleryData = $_read->fetchAll('
171
+ SELECT
172
+ main.entity_id, `main`.`value_id`, `main`.`value` AS `file`,
173
+ `value`.`position`, `value`.`disabled`,
174
+ `default_value`.`position` AS `position_default`,
175
+ `default_value`.`disabled` AS `disabled_default`
176
+ FROM `' . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_media_gallery') . '` AS `main`
177
+ LEFT JOIN `' . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_media_gallery_value') . '` AS `value`
178
+ ON main.value_id=value.value_id AND value.store_id=' . Mage::app()->getStore()->getId() . '
179
+ LEFT JOIN `' . Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_media_gallery_value') . '` AS `default_value`
180
+ ON main.value_id=default_value.value_id AND default_value.store_id=0
181
+ WHERE (
182
+ main.attribute_id = ' . $_read->quote($_mediaGalleryAttributeId) . ')
183
+ AND (main.entity_id IN (' . $_read->quote($all_ids) . '))
184
+ AND (value.disabled = 0 OR (value.disabled IS NULL AND `default_value`.`disabled` = 0))
185
+ GROUP BY main.entity_id
186
+
187
+ ORDER BY IF(value.position IS NULL, default_value.position, value.position) ASC
188
+ ');
189
+ foreach ($_mediaGalleryData as $_galleryImage) {
190
+ $k = $_galleryImage['entity_id'];
191
+ unset($_galleryImage['entity_id']);
192
+ if (!isset($_mediaGalleryByProductId[$k])) {
193
+ $_mediaGalleryByProductId[$k] = array();
194
+ }
195
+ $_mediaGalleryByProductId[$k][] = $_galleryImage;
196
+ }
197
+ unset($_mediaGalleryData);
198
+ }
199
+ return $_mediaGalleryByProductId;
200
+ }
201
+
202
+ public function getFinalPriceIncludingTax($product) {
203
+ return Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), 2);
204
+ }
205
+
206
+ public function getPriceIncludingTax($product) {
207
+ return Mage::helper('tax')->getPrice($product, $product->getPrice(), 2);
208
+ }
209
+
210
+ protected function _addAdditionalAttributes($collection) {
211
+ return $collection;
212
+ }
213
+
214
+ /**
215
+ * Gets "min_qty" value from config.
216
+ *
217
+ * @return int
218
+ */
219
+ protected function _getMinQty() {
220
+ if ($this->_minQty === false) {
221
+ $this->_minQty = $this->getConfig()->getMinQty();
222
+ }
223
+ return $this->_minQty;
224
+ }
225
+
226
+ /**
227
+ * Gets status for product in XML feed.
228
+ * If product is invisible, status equals 0.
229
+ * If product stock qty is lower than "min_qty" config value, status equals 0.
230
+ * Else, status equals 1.
231
+ *
232
+ * @param Mage_Catalog_Model_Product $product
233
+ * @return bool
234
+ */
235
+ protected function _getStatus($product) {
236
+ return $product->isVisibleInSiteVisibility() && $product->isVisibleInCatalog() && ($this->_getMinQty() ? $product->getQty() >= $this->_getMinQty() : true);
237
+ }
238
+
239
+ /**
240
+ * Gets id of a configurable product for specified child product
241
+ *
242
+ * @param Mage_Catalog_Model_Product $child
243
+ * @return int
244
+ */
245
+ public function getConfigurableIdByChildId($childId) {
246
+ $ids = Mage::getSingleton('catalog/product_type_configurable')->getParentIdsByChild($childId);
247
+ if (!empty($ids)) {
248
+ return (int) array_shift($ids);
249
+ }
250
+ return 0;
251
+ }
252
+
253
+ protected function getCategories($categoryIds) {
254
+ $categories = array();
255
+ $categoryIdsToAdd = array();
256
+ foreach ($categoryIds as $categoryId) {
257
+ if (!isset($this->_categories[$categoryId])) {
258
+ $categoryIdsToAdd[] = $categoryId;
259
+ } else {
260
+ $categories[$categoryId] = $this->_categories[$categoryId];
261
+ }
262
+ }
263
+ if (!empty($categoryIdsToAdd)) {
264
+ $collection = Mage::getModel('catalog/category')
265
+ ->getCollection()
266
+ ->addAttributeToSelect('name')
267
+ ->addAttributeToFilter('entity_id', $categoryIdsToAdd)
268
+ ->setPage(0, count($categoryIdsToAdd));
269
+ foreach ($collection as $category) {
270
+ $this->_categories[$category->getId()] = $category->getName();
271
+ $categories[$category->getId()] = $category->getName();
272
+ }
273
+ }
274
+ return $categories;
275
+ }
276
+
277
+ }
app/code/community/Quarticon/Quartic/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
3
+
4
+ protected function _initAction() {
5
+ return $this;
6
+ }
7
+
8
+ public function urlsAction() {
9
+ $this->_title($this->__('System'))
10
+ ->_title($this->__('Quartic'))
11
+ ->_title($this->__('Feed URLs'));
12
+ $this->loadLayout();
13
+ $this->renderLayout();
14
+ }
15
+
16
+ }
app/code/community/Quarticon/Quartic/controllers/FeedController.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Quarticon_Quartic_FeedController extends Mage_Core_Controller_Front_Action {
4
+
5
+ protected function getConfig() {
6
+ return Mage::getModel('quartic/config');
7
+ }
8
+
9
+ protected function _startXML() {
10
+ $hash = $this->getRequest()->getParam('hash');
11
+ if ($hash == $this->getConfig()->getHash() && $this->getConfig()->isActive()) {
12
+ return true;
13
+ } else {
14
+ return false;
15
+ }
16
+ }
17
+
18
+ public function productsAction() {
19
+ if ($this->_startXML()) {
20
+ header("Content-Type:text/xml");
21
+ $writer = new XMLWriter();
22
+ $writer->openUri('php://output');
23
+ $writer->startDocument('1.0', 'UTF-8');
24
+ $writer->setIndent(true);
25
+ $mem_writer = new XMLWriter();
26
+ $mem_writer->openMemory();
27
+ $mem_writer->setIndent(true);
28
+ $writer->startElement('products');
29
+ $_product = Mage::getModel('quartic/product');
30
+ $count = $_product->getCollectionCount();
31
+ $steps = ceil($count / Quarticon_Quartic_Model_Product::ITERATION_STEP);
32
+ for ($step = 1; $step <= $steps; $step++) {
33
+ $collection = $_product->getAll($step, Quarticon_Quartic_Model_Product::ITERATION_STEP);
34
+ foreach ($collection as &$p) {
35
+ $mem_writer->startElement('product');
36
+ $mem_writer->writeElement('id', $p['id']);
37
+ $mem_writer->startElement('title');
38
+ $mem_writer->writeCData($p['title']);
39
+ $mem_writer->endElement();
40
+ $mem_writer->startElement('link');
41
+ $mem_writer->writeCData($p['link']);
42
+ $mem_writer->endElement();
43
+ if (isset($p['thumb'])) {
44
+ $mem_writer->startElement('thumb');
45
+ $mem_writer->writeCData($p['thumb']);
46
+ $mem_writer->endElement();
47
+ }
48
+ $mem_writer->writeElement('price', $p['price']);
49
+ if (isset($p['old_price'])) {
50
+ $mem_writer->writeElement('old_price', $p['old_price']);
51
+ }
52
+ if (isset($p['author'])) {
53
+ $mem_writer->startElement('author');
54
+ $mem_writer->writeCData($p['author']);
55
+ $mem_writer->endElement();
56
+ }
57
+ $mem_writer->writeElement('status', $p['status'] ? '1' : '0');
58
+ $i = 0;
59
+ foreach ($p['categories'] as $categoryId => $categoryName) {
60
+ $i++;
61
+ $mem_writer->startElement('category_' . $i);
62
+ $mem_writer->writeAttribute('id', $categoryId);
63
+ $mem_writer->writeRaw($categoryName);
64
+ $mem_writer->endElement();
65
+ }
66
+ $mem_writer->endElement();
67
+ unset($p);
68
+ }
69
+ $batch_xml_string = $mem_writer->outputMemory(true);
70
+ $writer->writeRaw($batch_xml_string);
71
+ unset($collection);
72
+ }
73
+ unset($mem_writer);
74
+ $writer->endElement();
75
+ $writer->endDocument();
76
+ die();
77
+ } else {
78
+ $this->_redirect('/');
79
+ }
80
+ }
81
+
82
+ public function ordersAction() {
83
+ if ($this->_startXML()) {
84
+ header("Content-Type:text/xml");
85
+ $writer = new XMLWriter();
86
+ $writer->openUri('php://output');
87
+ $writer->startDocument('1.0', 'UTF-8');
88
+ $writer->setIndent(true);
89
+ $mem_writer = new XMLWriter();
90
+ $mem_writer->openMemory();
91
+ $mem_writer->setIndent(true);
92
+ $writer->startElement('orders');
93
+ $_order = Mage::getModel('quartic/order');
94
+ $count = $_order->getCollectionCount();
95
+ $steps = ceil($count / Quarticon_Quartic_Model_Order::ITERATION_STEP);
96
+ for ($step = 1; $step <= $steps; $step++) {
97
+ $collection = $_order->getAll($step, Quarticon_Quartic_Model_Order::ITERATION_STEP);
98
+ foreach ($collection as $o) {
99
+ $mem_writer->startElement('order');
100
+ $mem_writer->writeElement('transaction', $o['id']);
101
+ $mem_writer->writeElement('timestamp', $o['timestamp']);
102
+ $mem_writer->writeElement('user', $o['user']);
103
+ $mem_writer->writeElement('product', $o['product']);
104
+ $mem_writer->writeElement('quantity', $o['quantity']);
105
+ $mem_writer->writeElement('price', $o['price']);
106
+ $mem_writer->endElement();
107
+ unset($o);
108
+ }
109
+ $batch_xml_string = $mem_writer->outputMemory(true);
110
+ $writer->writeRaw($batch_xml_string);
111
+ unset($collection);
112
+ }
113
+ unset($mem_writer);
114
+ $writer->endElement();
115
+ $writer->endDocument();
116
+ die();
117
+ } else {
118
+ $this->_redirect('/');
119
+ }
120
+ }
121
+
122
+ }
app/code/community/Quarticon/Quartic/controllers/FrameController.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Quarticon_Quartic_FrameController extends Mage_Core_Controller_Front_Action {
3
+
4
+ protected function getConfig() {
5
+ return Mage::getModel('quartic/config');
6
+ }
7
+
8
+ public function IndexAction() {
9
+ $slot = $this->getRequest()->getParam('slot');
10
+ $block = $this->getLayout()->createBlock('quartic/products')->setTemplate('quartic/products/'.$slot.'.phtml');
11
+ $this->getResponse()->setBody($block->toHtml());
12
+ }
13
+
14
+ }
app/code/community/Quarticon/Quartic/etc/adminhtml.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <catalog>
5
+ <children>
6
+ <quartic translate="title" module="quartic">
7
+ <title>QUARTICON | Quartic</title>
8
+ <action>quartic/adminhtml_index/urls</action>
9
+ <sort_order>1500</sort_order>
10
+ </quartic>
11
+ </children>
12
+ </catalog>
13
+ </menu>
14
+ </config>
app/code/community/Quarticon/Quartic/etc/config.xml ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Quarticon_Quartic>
5
+ <version>0.3.3</version>
6
+ </Quarticon_Quartic>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <quartic>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Quarticon_Quartic</module>
14
+ <frontName>quartic</frontName>
15
+ </args>
16
+ </quartic>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <quartic>
21
+ <file>quartic.xml</file>
22
+ </quartic>
23
+ </updates>
24
+ </layout>
25
+ <translate>
26
+ <modules>
27
+ <Quarticon_Quartic>
28
+ <files>
29
+ <default>Quarticon_Quartic.csv</default>
30
+ </files>
31
+ </Quarticon_Quartic>
32
+ </modules>
33
+ </translate>
34
+ </frontend>
35
+ <global>
36
+ <blocks>
37
+ <quartic>
38
+ <class>Quarticon_Quartic_Block</class>
39
+ </quartic>
40
+ </blocks>
41
+ <models>
42
+ <quartic>
43
+ <class>Quarticon_Quartic_Model</class>
44
+ </quartic>
45
+ </models>
46
+ <resources>
47
+ <quartic_setup>
48
+ <setup>
49
+ <module>Quarticon_Quartic</module>
50
+ </setup>
51
+ <connection>
52
+ <use>core_setup</use>
53
+ </connection>
54
+ </quartic_setup>
55
+ <quartic_write>
56
+ <connection>
57
+ <use>core_write</use>
58
+ </connection>
59
+ </quartic_write>
60
+ <quartic_read>
61
+ <connection>
62
+ <use>core_read</use>
63
+ </connection>
64
+ </quartic_read>
65
+ </resources>
66
+ <helpers>
67
+ <quartic>
68
+ <class>Quarticon_Quartic_Helper</class>
69
+ </quartic>
70
+ </helpers>
71
+ </global>
72
+ <default>
73
+ <quartic>
74
+ <config>
75
+ <active>0</active>
76
+ <use_sku>1</use_sku>
77
+ <add_thumbs>0</add_thumbs>
78
+ <only_in_stock>0</only_in_stock>
79
+ <show_disabled_products>1</show_disabled_products>
80
+ <category_use_product_frame>0</category_use_product_frame>
81
+ <min_qty>0</min_qty>
82
+ </config>
83
+ </quartic>
84
+ </default>
85
+ <adminhtml>
86
+ <translate>
87
+ <modules>
88
+ <Quarticon_Quartic>
89
+ <files>
90
+ <default>Quarticon_Quartic.csv</default>
91
+ </files>
92
+ </Quarticon_Quartic>
93
+ </modules>
94
+ </translate>
95
+ <acl>
96
+ <resources>
97
+ <admin>
98
+ <children>
99
+ <system>
100
+ <children>
101
+ <config>
102
+ <children>
103
+ <quartic>
104
+ <title>QUARTICON | Quartic</title>
105
+ </quartic>
106
+ </children>
107
+ </config>
108
+ </children>
109
+ </system>
110
+ </children>
111
+ </admin>
112
+ </resources>
113
+ </acl>
114
+ <layout>
115
+ <updates>
116
+ <quartic>
117
+ <file>quartic.xml</file>
118
+ </quartic>
119
+ </updates>
120
+ </layout>
121
+ </adminhtml>
122
+ <admin>
123
+ <routers>
124
+ <quartic>
125
+ <use>admin</use>
126
+ <args>
127
+ <module>Quarticon_Quartic</module>
128
+ <frontName>quartic</frontName>
129
+ </args>
130
+ </quartic>
131
+ </routers>
132
+ </admin>
133
+ </config>
app/code/community/Quarticon/Quartic/etc/system.xml ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <quartic translate="label" module="quartic">
5
+ <label><![CDATA[<div class="quarticon-headline"></div>QUARTICON | Quartic]]></label>
6
+ <tab>general</tab>
7
+ <sort_order>1600</sort_order>
8
+ <show_in_default>1</show_in_default>
9
+ <show_in_website>1</show_in_website>
10
+ <show_in_store>1</show_in_store>
11
+ <groups>
12
+ <config translate="label">
13
+ <label>Configuration</label>
14
+ <sort_order>1</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>0</show_in_website>
17
+ <show_in_store>0</show_in_store>
18
+ <fields>
19
+ <active translate="label">
20
+ <label>Enabled</label>
21
+ <frontend_type>select</frontend_type>
22
+ <source_model>adminhtml/system_config_source_yesno</source_model>
23
+ <sort_order>10</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>0</show_in_website>
26
+ <show_in_store>0</show_in_store>
27
+ </active>
28
+ <customer translate="label">
29
+ <label>Customer</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>20</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>0</show_in_website>
34
+ <show_in_store>0</show_in_store>
35
+ </customer>
36
+ <hash translate="label,comment">
37
+ <label>Unique Hash</label>
38
+ <frontend_type>text</frontend_type>
39
+ <comment>This value is used for the feeds URLs generation</comment>
40
+ <sort_order>30</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>0</show_in_website>
43
+ <show_in_store>0</show_in_store>
44
+ </hash>
45
+ <use_sku translate="label,comment">
46
+ <label>Use SKU</label>
47
+ <comment>Disable if your SKUs are longer than 20 chars</comment>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>adminhtml/system_config_source_yesno</source_model>
50
+ <sort_order>40</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>0</show_in_website>
53
+ <show_in_store>0</show_in_store>
54
+ </use_sku>
55
+ <use_sku translate="label,comment">
56
+ <label>Use SKU</label>
57
+ <comment>Disable if your SKUs are longer than 20 chars</comment>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>adminhtml/system_config_source_yesno</source_model>
60
+ <sort_order>40</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>0</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ </use_sku>
65
+ <add_thumbs translate="label">
66
+ <label>Add thumbnails to XML</label>
67
+ <frontend_type>select</frontend_type>
68
+ <source_model>adminhtml/system_config_source_yesno</source_model>
69
+ <sort_order>55</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>0</show_in_website>
72
+ <show_in_store>0</show_in_store>
73
+ </add_thumbs>
74
+ <author translate="label">
75
+ <label>Author field in Products XML</label>
76
+ <frontend_type>select</frontend_type>
77
+ <source_model>quartic/attribute</source_model>
78
+ <sort_order>60</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>0</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ </author>
83
+ <show_disabled_products translate="label">
84
+ <label>Show disabled products in XML feed?</label>
85
+ <frontend_type>select</frontend_type>
86
+ <source_model>adminhtml/system_config_source_yesno</source_model>
87
+ <sort_order>70</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>0</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ </show_disabled_products>
92
+ <min_qty translate="label">
93
+ <label>Minimal product quantity for status equals 1</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>80</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>0</show_in_website>
98
+ <show_in_store>0</show_in_store>
99
+ <validate>validate-number validate-zero-or-greater</validate>
100
+ </min_qty>
101
+ </fields>
102
+ </config>
103
+ <frames translate="label">
104
+ <label>Recommendation frames</label>
105
+ <sort_order>2</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>0</show_in_website>
108
+ <show_in_store>0</show_in_store>
109
+ <fields>
110
+ <homepage translate="label">
111
+ <label>Homepage</label>
112
+ <frontend_type>select</frontend_type>
113
+ <source_model>adminhtml/system_config_source_yesno</source_model>
114
+ <sort_order>10</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>0</show_in_website>
117
+ <show_in_store>0</show_in_store>
118
+ </homepage>
119
+ <category translate="label">
120
+ <label>Category page</label>
121
+ <frontend_type>select</frontend_type>
122
+ <source_model>adminhtml/system_config_source_yesno</source_model>
123
+ <sort_order>20</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>0</show_in_website>
126
+ <show_in_store>0</show_in_store>
127
+ </category>
128
+ <category_use_product_frame translate="label,comment">
129
+ <label>Use product frame on category page</label>
130
+ <comment>Recommendations will be get for random product from a category</comment>
131
+ <frontend_type>select</frontend_type>
132
+ <source_model>adminhtml/system_config_source_yesno</source_model>
133
+ <sort_order>25</sort_order>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>0</show_in_website>
136
+ <show_in_store>0</show_in_store>
137
+ </category_use_product_frame>
138
+ <product translate="label">
139
+ <label>Product page</label>
140
+ <frontend_type>select</frontend_type>
141
+ <source_model>adminhtml/system_config_source_yesno</source_model>
142
+ <sort_order>30</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>0</show_in_website>
145
+ <show_in_store>0</show_in_store>
146
+ </product>
147
+ <cart translate="label">
148
+ <label>Cart</label>
149
+ <frontend_type>select</frontend_type>
150
+ <source_model>adminhtml/system_config_source_yesno</source_model>
151
+ <sort_order>40</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>0</show_in_website>
154
+ <show_in_store>0</show_in_store>
155
+ </cart>
156
+ </fields>
157
+ </frames>
158
+ </groups>
159
+ </quartic>
160
+ </sections>
161
+ </config>
app/code/community/Quarticon/Quartic/sql/quartic_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ Mage::getModel('quartic/config')->saveHash();
6
+
7
+ @mail('contact@quarticon.com', '[Install] Quartic 0.1.0', "IP: ".$_SERVER['SERVER_ADDR']."\r\nHost: ".gethostbyaddr($_SERVER['SERVER_ADDR']), "From: ".(Mage::getStoreConfig('general/store_information/email_address') ? Mage::getStoreConfig('general/store_information/email_address') : 'contact@quarticon.com'));
8
+
9
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/quartic.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss">
6
+ <name>quartic.css</name>
7
+ </action>
8
+ </reference>
9
+ </default>
10
+ <quartic_adminhtml_index_urls>
11
+ <reference name="content">
12
+ <block type="quartic/admin_urls" name="quartic_urls" />
13
+ </reference>
14
+ </quartic_adminhtml_index_urls>
15
+ </layout>
app/design/adminhtml/default/default/template/quartic/urls.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0">
3
+ <tr>
4
+ <td style="width:50%;"><h3><?php echo Mage::helper('quartic')->__('Quartic feed URLs') ?></h3></td>
5
+ </tr>
6
+ </table>
7
+ </div>
8
+ <div>
9
+ <?php echo $this->getGridHtml() ?>
10
+ </div>
app/design/frontend/base/default/layout/quartic.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="before_body_end">
5
+ <block type="quartic/script" name="quartic_script" template="quartic/script.phtml" />
6
+ </reference>
7
+ </default>
8
+ <catalog_product_view>
9
+ <reference name="before_body_end">
10
+ <block type="quartic/getter_product" name="quartic_getter_product" before="quartic_script" template="quartic/getter/product.phtml" />
11
+ </reference>
12
+ <reference name="content">
13
+ <block type="quartic/frame_product" name="quartic_frame_product" after="-" template="quartic/frame/product.phtml" />
14
+ </reference>
15
+ </catalog_product_view>
16
+ <checkout_onepage_success>
17
+ <reference name="before_body_end">
18
+ <block type="quartic/getter_order" name="quartic_getter_order" before="quartic_script" template="quartic/getter/order.phtml" />
19
+ </reference>
20
+ </checkout_onepage_success>
21
+ <cms_index_index>
22
+ <reference name="content">
23
+ <block type="quartic/frame_home" name="quartic_frame_home" after="-" template="quartic/frame/home.phtml" />
24
+ </reference>
25
+ </cms_index_index>
26
+ <catalog_category_default>
27
+ <reference name="content">
28
+ <block type="quartic/frame_category" name="quartic_frame_category" after="-" />
29
+ </reference>
30
+ </catalog_category_default>
31
+ <catalog_category_layered>
32
+ <reference name="content">
33
+ <block type="quartic/frame_category" name="quartic_frame_category" after="-" />
34
+ </reference>
35
+ </catalog_category_layered>
36
+ <checkout_cart_index>
37
+ <reference name="content">
38
+ <block type="quartic/frame_cart" name="quartic_frame_cart" after="-" template="quartic/frame/cart.phtml" />
39
+ </reference>
40
+ </checkout_cart_index>
41
+ </layout>
app/design/frontend/base/default/template/quartic/frame/cart.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isActive()): ?>
2
+ <div id="slt_cart"></div>
3
+ <script type="text/javascript">
4
+ var upsParams = upsParams || [];
5
+ upsParams.push(['action','recommend']);
6
+ upsParams.push(['tag_id','quartic_cart']);
7
+ upsParams.push(['customer', '<?php echo $this->getCustomer(); ?>']);
8
+ upsParams.push(['slot', 'slt_cart']);
9
+ upsParams.push(['user', '<?php echo $this->getUser(); ?>']);
10
+ upsParams.push(['products', '<?php echo $this->getProducts(); ?>']);
11
+ upsParams.push(['execute']);
12
+ </script>
13
+ <?php endif; ?>
app/design/frontend/base/default/template/quartic/frame/category.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isActive()): ?>
2
+ <div id="slt_category"></div>
3
+ <script type="text/javascript">
4
+ var upsParams = upsParams || []
5
+ upsParams.push(['action','recommend']);
6
+ upsParams.push(['tag_id','quartic_category']);
7
+ upsParams.push(['customer', '<?php echo $this->getCustomer(); ?>']);
8
+ upsParams.push(['slot', 'slt_category']);
9
+ upsParams.push(['user', '<?php echo $this->getUser(); ?>']);
10
+ upsParams.push(['filter', '<?php echo $this->getCurrentCategory()->getId(); ?>']);
11
+ upsParams.push(['execute']);
12
+ </script>
13
+ <?php endif; ?>
app/design/frontend/base/default/template/quartic/frame/home.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isActive()): ?>
2
+ <div id="slt_home"></div>
3
+ <script type="text/javascript">
4
+ var upsParams = upsParams || [];
5
+ upsParams.push(['action','recommend']);
6
+ upsParams.push(['tag_id','quartic_home']);
7
+ upsParams.push(['customer', '<?php echo $this->getCustomer(); ?>']);
8
+ upsParams.push(['slot', 'slt_home']);
9
+ upsParams.push(['user', '<?php echo $this->getUser(); ?>']);
10
+ upsParams.push(['execute']);
11
+ </script>
12
+ <?php endif; ?>
app/design/frontend/base/default/template/quartic/frame/product.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isActive()): ?>
2
+ <?php $productId = $this->getProductId(); ?>
3
+ <?php if ($productId): ?>
4
+ <div id="slt_product"></div>
5
+ <script type="text/javascript">
6
+ var upsParams = upsParams || [];
7
+ upsParams.push(['action','recommend']);
8
+ upsParams.push(['tag_id','quartic_product']);
9
+ upsParams.push(['customer', '<?php echo $this->getCustomer(); ?>']);
10
+ upsParams.push(['slot', 'slt_product']);
11
+ upsParams.push(['user', '<?php echo $this->getUser(); ?>']);
12
+ upsParams.push(['product', '<?php echo $productId; ?>']);
13
+ upsParams.push(['execute']);
14
+ </script>
15
+ <?php endif; ?>
16
+ <?php endif; ?>
app/design/frontend/base/default/template/quartic/getter/order.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isActive()): ?>
2
+ <?php $order = $this->getOrder(); ?>
3
+ <?php $order_items = $this->getProducts(); ?>
4
+ <script type="text/javascript">
5
+ var upsParams = upsParams || [];
6
+ upsParams.push(['customer','<?php echo $this->getCustomer(); ?>']);
7
+ upsParams.push(['transaction', '<?php echo $order->getIncrementId(); ?>']);
8
+ upsParams.push(['user', '<?php echo $this->getUser(); ?>']);
9
+ <?php foreach ($order_items as $item): ?>
10
+ upsParams.push(['action','purchase']);    
11
+ upsParams.push(['product','<?php echo $item['product']; ?>']);
12
+ upsParams.push(['price','<?php echo $item['price']; ?>']);
13
+ upsParams.push(['quantity','<?php echo $item['quantity']; ?>']);
14
+ upsParams.push(['execute']);
15
+ <?php endforeach; ?>
16
+ </script>
17
+ <?php endif; ?>
app/design/frontend/base/default/template/quartic/getter/product.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isActive()): ?>
2
+ <script type="text/javascript">
3
+     var upsParams = upsParams || []
4
+     upsParams.push(['action','view'])
5
+     upsParams.push(['customer','<?php echo $this->getCustomer(); ?>'])
6
+     upsParams.push(['user', '<?php echo $this->getUser(); ?>'])
7
+     upsParams.push(['product', '<?php echo Mage::helper('quartic')->getProduct($this->getProduct()); ?>'])
8
+ upsParams.push(['execute'])
9
+ </script>
10
+ <?php endif; ?>
app/design/frontend/base/default/template/quartic/products.phtml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $_productCollection=$this->getLoadedProductCollection();
3
+ $_helper = $this->helper('catalog/output');
4
+ ?>
5
+ <?php if ($_productCollection->count()): ?>
6
+ <h2><?php echo Mage::helper('quartic')->__('Recommendations'); ?></h2>
7
+ <div class="category-products">
8
+ <?php // List mode ?>
9
+ <?php if($this->getMode()!='grid'): ?>
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 $this->getQuarticUrl($_product) ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
16
+ <?php // Product description ?>
17
+ <div class="product-shop">
18
+ <div class="f-fix">
19
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
20
+ <h2 class="product-name"><a href="<?php echo $this->getQuarticUrl($_product) ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
21
+ <?php if($_product->getRatingSummary()): ?>
22
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
23
+ <?php endif; ?>
24
+ <?php echo $this->getPriceHtml($_product, true) ?>
25
+ <?php if($_product->isSaleable()): ?>
26
+ <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getQuarticAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
27
+ <?php else: ?>
28
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
29
+ <?php endif; ?>
30
+ <div class="desc std">
31
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
32
+ <a href="<?php echo $this->getQuarticUrl($_product) ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
33
+ </div>
34
+ <ul class="add-to-links">
35
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
36
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
37
+ <?php endif; ?>
38
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
39
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
40
+ <?php endif; ?>
41
+ </ul>
42
+ </div>
43
+ </div>
44
+ </li>
45
+ <?php endforeach; ?>
46
+ </ol>
47
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
48
+
49
+ <?php else: ?>
50
+
51
+ <?php // Grid Mode ?>
52
+
53
+ <?php $_collectionSize = $_productCollection->count() ?>
54
+ <?php $_columnCount = $this->getColumnCount(); ?>
55
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
56
+ <?php if ($i++%$_columnCount==0): ?>
57
+ <ul class="products-grid">
58
+ <?php endif ?>
59
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
60
+ <a href="<?php echo $this->getQuarticUrl($_product) ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
61
+ <h2 class="product-name"><a href="<?php echo $this->getQuarticUrl($_product) ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
62
+ <?php if($_product->getRatingSummary()): ?>
63
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
64
+ <?php endif; ?>
65
+ <?php echo $this->getPriceHtml($_product, true) ?>
66
+ <div class="actions">
67
+ <?php if($_product->isSaleable()): ?>
68
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getQuarticAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
69
+ <?php else: ?>
70
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
71
+ <?php endif; ?>
72
+ <ul class="add-to-links">
73
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
74
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
75
+ <?php endif; ?>
76
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
77
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
78
+ <?php endif; ?>
79
+ </ul>
80
+ </div>
81
+ </li>
82
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
83
+ </ul>
84
+ <?php endif ?>
85
+ <?php endforeach ?>
86
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
87
+ <?php endif; ?>
88
+
89
+ </div>
90
+ <?php endif; ?>
app/design/frontend/base/default/template/quartic/products/slt_cart.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php require_once(Mage::getBaseDir("app").'/design/frontend/base/default/template/quartic/products.phtml'); ?>
app/design/frontend/base/default/template/quartic/products/slt_category.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php require_once(Mage::getBaseDir("app").'/design/frontend/base/default/template/quartic/products.phtml'); ?>
app/design/frontend/base/default/template/quartic/products/slt_home.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php require_once(Mage::getBaseDir("app").'/design/frontend/base/default/template/quartic/products.phtml'); ?>
app/design/frontend/base/default/template/quartic/products/slt_product.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <?php require_once(Mage::getBaseDir("app").'/design/frontend/base/default/template/quartic/products.phtml'); ?>
app/design/frontend/base/default/template/quartic/script.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isActive()): ?>
2
+ <script type="text/javascript">
3
+ var upsScript = document.createElement('script');
4
+ var upsProtocol = ((document.location.protocol=='https:')?'https://secu':'http://');
5
+ upsScript.setAttribute('type','text/javascript');
6
+ upsScript.setAttribute('src', upsProtocol+'rec.quartic.pl/quartic.js');
7
+ upsScript.setAttribute('async','async');
8
+ var upsAnchor = document.getElementsByTagName('script')[0];
9
+ upsAnchor.parentNode.insertBefore(upsScript, upsAnchor);
10
+ function quartic_rec (recommendations, slot) {
11
+ var parameters = { slot: slot };
12
+ var i;
13
+ var count = recommendations.length;
14
+ for (var i = 0; i < count; i++) {
15
+ parameters['sku[' + i + ']'] = recommendations[i][0];
16
+ parameters['url[' + i + ']'] = recommendations[i][1];
17
+ }
18
+ new Ajax.Request('<?php echo Mage::getUrl('quartic/frame/index'); ?>', {
19
+ method: 'post',
20
+ parameters: parameters,
21
+ onSuccess: function(transport) {
22
+ $(slot).update(transport.responseText);
23
+ }
24
+ });
25
+ }
26
+ </script>
27
+ <?php endif; ?>
app/etc/modules/Quarticon_Quartic.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Quarticon_Quartic>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Quarticon_Quartic>
8
+ </modules>
9
+ </config>
app/locale/pl_PL/Quarticon_Quartic.csv ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Add thumbnails to XML","Dodaj miniaturki zdjęć do XML-a"
2
+ "Author field in Products XML","Pole 'autor' w XML-u z produktami"
3
+ "Cart","Koszyk"
4
+ "Category page","Strona kategorii"
5
+ "Configuration","Konfiguracja"
6
+ "Disable if your SKUs are longer than 20 chars","Wyłącz, jeżeli Twoje SKU mają więcej niż 20 znaków"
7
+ "Feed URLs","URL-e feedów"
8
+ "Homepage","Strona główna"
9
+ "Minimal product quantity for status equals 1","Minimalny stan magazynowy produktu, żeby jego status był równy 1"
10
+ "Product page","Karta produktu"
11
+ "Quartic feed URLs","URL-e feedów Quartic"
12
+ "Quartic Orders URL","URL feeda z zamówieniami"
13
+ "Quartic Products URL","URL feeda z produktami"
14
+ "Recommendation frames","Ramki z rekomendacjami"
15
+ "Recommendations","Rekomendacje"
16
+ "Recommendations will be get for random product from a category","Rekomendacje zostaną wygenerowane dla losowego produktu z kategorii"
17
+ "Show disabled products in XML feed?","Czy pokazywać w feedzie XML produkty ze statusem 'Nie'?"
18
+ "Show only products in stock","Pokazuj tylko produkty na stanie w magazynie"
19
+ "Store ID","ID sklepu"
20
+ "This value is used for the feeds URLs generation","Ta wartość jest używana do tworzenia URL-i feedów"
21
+ "Unique Hash","Unikalny hash"
22
+ "Use product frame on category page","Użyj ramki produktowej na stronie kategorii"
23
+ "Use SKU","Używaj SKU"
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Quarticon_Quartic</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Recommend - personalized product recommendations, by QuarticON.com</summary>
10
+ <description>Recommend - personalized product recommendations, by QuarticON.com</description>
11
+ <notes>The extension integrates your store with Quartic platform.</notes>
12
+ <authors><author><name>QuarticON</name><user>quarticon</user><email>contact@quarticon.com</email></author></authors>
13
+ <date>2015-02-18</date>
14
+ <time>12:05:47</time>
15
+ <contents><target name="magecommunity"><dir name="Quarticon"><dir name="Quartic"><dir name="Block"><dir name="Admin"><dir name="Urls"><file name="Grid.php" hash="11e5533b95c0c566282f0a4ace55e5f8"/></dir><file name="Urls.php" hash="65341f13fd050d3f6f51bff192a194e2"/></dir><file name="Box.php" hash="9dffee16dcd2edb819831474d977c6b6"/><dir name="Frame"><file name="Cart.php" hash="e12ce27dfa6adf356b0872d41140f33f"/><file name="Category.php" hash="3c497ccf32afaadf62c6ce78ec9571f5"/><file name="Home.php" hash="ab3866886609f2d3d04880c64991b010"/><file name="Product.php" hash="9f4204f18091debf5a02a6ac1c6b5d72"/></dir><dir name="Getter"><file name="Order.php" hash="d54ebee6e8491cf348593a5aeabb7ce2"/><file name="Product.php" hash="777f47bf10cd57c82ea7b7965887de02"/></dir><file name="Products.php" hash="4c82be1ce1c53fbe83dbb5d567ad9456"/><file name="Script.php" hash="da4be020e5bf9fa8f07468ae5162c5e9"/></dir><dir name="Helper"><file name="Data.php" hash="89cd14f50d3963999dc1827e569a3f2f"/></dir><dir name="Model"><file name="Attribute.php" hash="a7f8b80d5d3189e0830c88d814af7c13"/><file name="Config.php" hash="42c16946192251e58d5e8cc4f8020386"/><file name="Order.php" hash="ee906b0f8706e7ccde62d3c30b6e418c"/><file name="Product.php" hash="169cb771876ec3dc920bb69b005e72c8"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="9e0242e2d39056dec1212eefedb6280e"/></dir><file name="FeedController.php" hash="fe6c0bf163676fc3dc48683cd5019b0b"/><file name="FrameController.php" hash="cd488ed4e5d0015c1a49f054ee31bde2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8b160fdde01ed789be779f0020bcbc5f"/><file name="config.xml" hash="049f92d9635f0337d98af25cf167436e"/><file name="system.xml" hash="b232649cacbf1d257f4df90d7c0294ac"/></dir><dir name="sql"><dir name="quartic_setup"><file name="mysql4-install-0.1.0.php" hash="519072a67073b91d13090b9baf72a9ca"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="quartic.xml" hash="47d4cb722d8f1c4b5da3d8cdeadc4d86"/></dir><dir name="template"><dir name="quartic"><file name="urls.phtml" hash="9e851635f6c1737e5db9081baa222174"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="quartic.xml" hash="f60b921b27a41960cfab52c91fad5f1f"/></dir><dir name="template"><dir name="quartic"><dir name="frame"><file name="cart.phtml" hash="feaf43bf64b342455abee94960b8c98b"/><file name="category.phtml" hash="177e6d66b3bde2e6bab8afb927fb4f25"/><file name="home.phtml" hash="9b56f028de68c1c0568b9c68d1109cea"/><file name="product.phtml" hash="5151e728a35e262bf2c1ac4e0777c625"/></dir><dir name="getter"><file name="order.phtml" hash="2f235846a58896384fcb9c39162e5334"/><file name="product.phtml" hash="b493b7a319b7530a82962c3395706e68"/></dir><dir name="products"><file name="slt_cart.phtml" hash="b534e86c913c3e5c7a59956980055e9a"/><file name="slt_category.phtml" hash="b534e86c913c3e5c7a59956980055e9a"/><file name="slt_home.phtml" hash="b534e86c913c3e5c7a59956980055e9a"/><file name="slt_product.phtml" hash="b534e86c913c3e5c7a59956980055e9a"/></dir><file name="products.phtml" hash="2402fe0ce2153e9520a74457b5e96495"/><file name="script.phtml" hash="6a409651fdd0a2717227d157338d3ad7"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Quarticon_Quartic.xml" hash="7b123838bd21dca630ee2c92d3ef3194"/></dir></target><target name="magelocale"><dir name="pl_PL"><file name="Quarticon_Quartic.csv" hash="ad6b16dfbd0b86a33159c611887f6f1e"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="quarticon-icon.png" hash="75db9de222be47ea963f5432ef8b3ef3"/></dir><file name="quartic.css" hash="10ee6a842ad0c394cecebc310a286358"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/images/quarticon-icon.png ADDED
Binary file
skin/adminhtml/default/default/quartic.css ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ .quarticon-headline {
2
+ background: url('images/quarticon-icon.png') no-repeat;
3
+ display: inline;
4
+ width: 25px; height: 20px;
5
+ float: left;
6
+ background-size: 20px 20px;
7
+ }