Version Notes
Removed Mage_Checkout CartController rewrite.
Added interface for StockCheck helper.
Extension moved to community code pool.
Download this release
Release Info
Developer | Sitewards Magento Team |
Extension | Sitewards_StockCheck_Framework |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- app/code/community/Sitewards/StockCheck/Helper/Data.php +83 -0
- app/code/community/Sitewards/StockCheck/Helper/Interface.php +32 -0
- app/code/community/Sitewards/StockCheck/Model/Cart/Observer.php +68 -0
- app/code/community/Sitewards/StockCheck/Model/Product.php +117 -0
- app/code/{local → community}/Sitewards/StockCheck/etc/config.xml +31 -13
- app/code/{local → community}/Sitewards/StockCheck/etc/system.xml +176 -132
- app/code/local/Sitewards/StockCheck/Helper/Data.php +0 -55
- app/code/local/Sitewards/StockCheck/Model/Product.php +0 -96
- app/code/local/Sitewards/StockCheck/controllers/CartController.php +0 -45
- app/etc/modules/Sitewards_StockCheck.xml +12 -8
- package.xml +12 -9
app/code/community/Sitewards/StockCheck/Helper/Data.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category Sitewards
|
5 |
+
* @package Sitewards_StockCheck
|
6 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
7 |
+
*
|
8 |
+
* This class is used to help the Sitewards_StockCheck_Model_Product class
|
9 |
+
*/
|
10 |
+
class Sitewards_StockCheck_Helper_Data extends Mage_Core_Helper_Abstract
|
11 |
+
implements Sitewards_StockCheck_Helper_Interface
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Green stock product status id
|
15 |
+
*
|
16 |
+
* @var int
|
17 |
+
*/
|
18 |
+
protected $iStockGreenId;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Yellow stock product status id
|
22 |
+
*
|
23 |
+
* @var int
|
24 |
+
*/
|
25 |
+
protected $iStockYellowId;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Red stock product status id
|
29 |
+
*
|
30 |
+
* @var int
|
31 |
+
*/
|
32 |
+
protected $iStockRedId;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Off stock product status id
|
36 |
+
*
|
37 |
+
* @var int
|
38 |
+
*/
|
39 |
+
protected $iStockOffId;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Define helper properties
|
43 |
+
*/
|
44 |
+
public function __construct() {
|
45 |
+
$this->iStockGreenId = Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_id');
|
46 |
+
$this->iStockYellowId = Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_id');
|
47 |
+
$this->iStockRedId = Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_id');
|
48 |
+
$this->iStockOffId = Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_off_id');
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
*
|
53 |
+
* @param int|string $mProductSku unique identifier for a product - defaults to Magento ProductId
|
54 |
+
* @return int real time stock level
|
55 |
+
*/
|
56 |
+
public function getCustomQuantity($mProductSku) {
|
57 |
+
Mage::throwException(
|
58 |
+
$this->__('StockCheck extension not correctly setup. Please complete the function getCustomQuantity in the helper %s', get_class())
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @param int|string $mProductSku unique identifier for a product - defaults to Magento ProductId
|
65 |
+
* @return int constant related to real time stock level
|
66 |
+
*/
|
67 |
+
public function getStorageType($mProductSku) {
|
68 |
+
Mage::throwException(
|
69 |
+
$this->__('StockCheck extension not correctly setup. Please complete the function getStorageType in the helper %s', get_class())
|
70 |
+
);
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
*
|
75 |
+
* @param int|string $mProductSku unique identifier for a product - defaults to Magento ProductId
|
76 |
+
* @return int current amount of stock taking into account the items on order
|
77 |
+
*/
|
78 |
+
public function getProductsStockOrder($mProductSku) {
|
79 |
+
Mage::throwException(
|
80 |
+
$this->__('StockCheck extension not correctly setup. Please complete the function getProductsStockOrder in the helper %s', get_class())
|
81 |
+
);
|
82 |
+
}
|
83 |
+
}
|
app/code/community/Sitewards/StockCheck/Helper/Interface.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category Sitewards
|
5 |
+
* @package Sitewards_StockCheck
|
6 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
7 |
+
*
|
8 |
+
* Interface for helper to help the Sitewards_StockCheck_Model_Product class
|
9 |
+
*/
|
10 |
+
interface Sitewards_StockCheck_Helper_Interface
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
* @param int|string $mxdProductSku unique identifier for a product - defaults to Magento ProductId
|
15 |
+
* @return int real time stock level
|
16 |
+
*/
|
17 |
+
public function getCustomQuantity($mxdProductSku);
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @param int|string $mxdProductSku unique identifier for a product - defaults to Magento ProductId
|
22 |
+
* @return int constant related to real time stock level
|
23 |
+
*/
|
24 |
+
public function getStorageType($mxdProductSku);
|
25 |
+
|
26 |
+
/**
|
27 |
+
*
|
28 |
+
* @param int|string $mxdProductSku unique identifier for a product - defaults to Magento ProductId
|
29 |
+
* @return int current amount of stock taking into account the items on order
|
30 |
+
*/
|
31 |
+
public function getProductsStockOrder($mxdProductSku);
|
32 |
+
}
|
app/code/community/Sitewards/StockCheck/Model/Cart/Observer.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sitewards_StockCheck_Model_Cart_Observer
|
4 |
+
* - Observer is used to look for the Mage_Checkout_Block_Cart
|
5 |
+
*
|
6 |
+
* @category Sitewards
|
7 |
+
* @package Sitewards_StockCheck
|
8 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
9 |
+
*/
|
10 |
+
class Sitewards_StockCheck_Model_Cart_Observer
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Check for stock levels and display a message if required
|
14 |
+
*
|
15 |
+
* @param Varien_Event_Observer $oObserver
|
16 |
+
*/
|
17 |
+
public function onCoreBlockAbstractToHtmlBefore(Varien_Event_Observer $oObserver)
|
18 |
+
{
|
19 |
+
if(Mage::getStoreConfig('stockcheck_config/stockcheck_group/disable_ext')) {
|
20 |
+
if ($oObserver->getData('block') instanceof Mage_Checkout_Block_Cart) {
|
21 |
+
$sProductIdentifierName = Mage::getStoreConfig('stockcheck_config/stockcheck_group/product_identifier_name');
|
22 |
+
$oCart = Mage::getSingleton('checkout/cart');
|
23 |
+
foreach($oCart->getItems() as $oItem) {
|
24 |
+
$oProduct = $oItem->getProduct();
|
25 |
+
$sArtnr = $oProduct->getData($sProductIdentifierName);
|
26 |
+
if(empty($sArtnr)) {
|
27 |
+
$oProduct->load($oProduct->getId());
|
28 |
+
}
|
29 |
+
$iActualUnits = $oItem->getProduct()->getQty();
|
30 |
+
$iPurchasedUnits = $oItem->getQty();
|
31 |
+
|
32 |
+
$aProductStockInfo = $oProduct->getStockAsLight($iPurchasedUnits);
|
33 |
+
|
34 |
+
$sErrorMessage = null;
|
35 |
+
switch($aProductStockInfo['id']) {
|
36 |
+
case Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_off_id'):
|
37 |
+
$sErrorMessage = 'This article is not a stock item and will be replenished in about 2-4 days.';
|
38 |
+
break;
|
39 |
+
|
40 |
+
case Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_id'):
|
41 |
+
if($iActualUnits > 0) {
|
42 |
+
$sErrorMessage = 'We currently only have %d units in stock, the remaining %d are on order from the manufacturer, so there should be no delay in delivery';
|
43 |
+
} else {
|
44 |
+
$sErrorMessage = 'Item is currently out of stock, but has been ordered. There should be no delivery delays';
|
45 |
+
}
|
46 |
+
break;
|
47 |
+
|
48 |
+
case Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_id'):
|
49 |
+
if($iActualUnits > 0) {
|
50 |
+
$sErrorMessage = 'We currently only have %d units in stock, the remaining %d units will be in stock in 2-4 working days';
|
51 |
+
} else {
|
52 |
+
$sErrorMessage = 'This item is currently out of stock and is on backorder in 2-4 working days';
|
53 |
+
}
|
54 |
+
break;
|
55 |
+
}
|
56 |
+
if(!is_null($sErrorMessage)) {
|
57 |
+
$oMessageFactory = Mage::getSingleton('core/message');
|
58 |
+
$oMessage = $oMessageFactory->error(
|
59 |
+
Mage::helper('checkout')->__(
|
60 |
+
$sErrorMessage, $iActualUnits, $iPurchasedUnits - $iActualUnits)
|
61 |
+
);
|
62 |
+
$oCart->getCheckoutSession()->addQuoteItemMessage($oItem->getId(), $oMessage);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
app/code/community/Sitewards/StockCheck/Model/Product.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @category Sitewards
|
5 |
+
* @package Sitewards_StockCheck
|
6 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
7 |
+
*
|
8 |
+
* This class is used to disable Magento´s default Quantity calculations
|
9 |
+
*/
|
10 |
+
class Sitewards_StockCheck_Model_Product extends Mage_Catalog_Model_Product
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Attribute name on which to identify products
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_sProductIdentifierName;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Extension active flag
|
21 |
+
*
|
22 |
+
* @var boolean
|
23 |
+
*/
|
24 |
+
protected $_bExtensionActive;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* StockCheck helper
|
28 |
+
*
|
29 |
+
* @var Sitewards_StockCheck_Helper_Interface
|
30 |
+
*/
|
31 |
+
protected $_oHelper;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Define all properties and check helper instance
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
$helperName = Mage::getStoreConfig('stockcheck_config/stockcheck_group/helper_name');
|
38 |
+
$this->_sProductIdentifierName = Mage::getStoreConfig('stockcheck_config/stockcheck_group/product_identifier_name');
|
39 |
+
$this->_bExtensionActive = Mage::getStoreConfig('stockcheck_config/stockcheck_group/disable_ext');
|
40 |
+
$this->_oHelper = Mage::Helper($helperName);
|
41 |
+
if (!($this->_oHelper instanceof Sitewards_StockCheck_Helper_Interface)) {
|
42 |
+
Mage::throwException(
|
43 |
+
Mage::Helper('stockcheck')->__('StockCheck extension not correctly setup. Helper %s should be instance of Sitewards_StockCheck_Helper_Interface.', $helperName)
|
44 |
+
);
|
45 |
+
}
|
46 |
+
parent::__construct();
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
*
|
51 |
+
* @return int stock level from external source or Mage_Catalog_Model_Product
|
52 |
+
*/
|
53 |
+
public function getQty() {
|
54 |
+
if($this->_bExtensionActive == true) {
|
55 |
+
$strProductIdentifierValue = $this->_getData($this->_sProductIdentifierName);
|
56 |
+
$intCustomQty = $this->_oHelper->getCustomQuantity($strProductIdentifierValue);
|
57 |
+
if(!is_null($intCustomQty)) {
|
58 |
+
return $intCustomQty;
|
59 |
+
} else {
|
60 |
+
parent::getQty();
|
61 |
+
}
|
62 |
+
} else {
|
63 |
+
parent::getQty();
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
*
|
69 |
+
* @param int $intQuantity requested level of quantity for a product - defaults to 1
|
70 |
+
* @return array contianing the source and alt text of stock light
|
71 |
+
*/
|
72 |
+
public function getStockAsLight($intQuantity = 1) {
|
73 |
+
if($this->_bExtensionActive != true) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
$strProductIdentifierValue = $this->_getData($this->_sProductIdentifierName);
|
77 |
+
|
78 |
+
$intStorageTypeId = $this->_oHelper->getStorageType($strProductIdentifierValue, $intQuantity);
|
79 |
+
|
80 |
+
switch($intStorageTypeId) {
|
81 |
+
case Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_id'):
|
82 |
+
return array(
|
83 |
+
'id' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_id'),
|
84 |
+
'source' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_img'),
|
85 |
+
'alt' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_text'),
|
86 |
+
'hover' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_hover')
|
87 |
+
);
|
88 |
+
break;
|
89 |
+
|
90 |
+
case Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_id'):
|
91 |
+
return array(
|
92 |
+
'id' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_id'),
|
93 |
+
'source' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_img'),
|
94 |
+
'alt' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_text'),
|
95 |
+
'hover' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_hover')
|
96 |
+
);
|
97 |
+
break;
|
98 |
+
|
99 |
+
case Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_id'):
|
100 |
+
return array(
|
101 |
+
'id' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_id'),
|
102 |
+
'source' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_img'),
|
103 |
+
'alt' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_text'),
|
104 |
+
'hover' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_hover')
|
105 |
+
);
|
106 |
+
break;
|
107 |
+
|
108 |
+
default:
|
109 |
+
return array(
|
110 |
+
'id' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_off_id'),
|
111 |
+
'source' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_off_img'),
|
112 |
+
'alt' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_off_text'),
|
113 |
+
'hover' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_off_hover')
|
114 |
+
);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
app/code/{local → community}/Sitewards/StockCheck/etc/config.xml
RENAMED
@@ -1,8 +1,16 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Sitewards_StockCheck>
|
5 |
-
<version>1.0.
|
6 |
</Sitewards_StockCheck>
|
7 |
</modules>
|
8 |
|
@@ -15,16 +23,20 @@
|
|
15 |
</stockcheck_group>
|
16 |
<stockcheck_img>
|
17 |
<stock_green_id>1</stock_green_id>
|
18 |
-
<stock_green_text>Item is in stock
|
|
|
19 |
<stock_green_img>/images/stock_green.gif</stock_green_img>
|
20 |
<stock_yellow_id>2</stock_yellow_id>
|
21 |
-
<stock_yellow_text>Item is
|
|
|
22 |
<stock_yellow_img>/images/stock_yellow.gif</stock_yellow_img>
|
23 |
<stock_red_id>3</stock_red_id>
|
24 |
-
<stock_red_text>Item is currently out of stock
|
|
|
25 |
<stock_red_img>/images/stock_red.gif</stock_red_img>
|
26 |
<stock_off_id>4</stock_off_id>
|
27 |
-
<stock_off_text>Item is not a stock item
|
|
|
28 |
<stock_off_img>/images/stock_off.gif</stock_off_img>
|
29 |
</stockcheck_img>
|
30 |
</stockcheck_config>
|
@@ -39,18 +51,14 @@
|
|
39 |
<frontName>StockCheck</frontName>
|
40 |
</args>
|
41 |
</Sitewards_StockCheck>
|
42 |
-
<checkout>
|
43 |
-
<args>
|
44 |
-
<modules>
|
45 |
-
<Sitewards_StockCheck before="Mage_Checkout">Sitewards_StockCheck</Sitewards_StockCheck>
|
46 |
-
</modules>
|
47 |
-
</args>
|
48 |
-
</checkout>
|
49 |
</routers>
|
50 |
</frontend>
|
51 |
|
52 |
<global>
|
53 |
<models>
|
|
|
|
|
|
|
54 |
<catalog>
|
55 |
<rewrite>
|
56 |
<product>Sitewards_StockCheck_Model_Product</product>
|
@@ -62,7 +70,17 @@
|
|
62 |
<class>Sitewards_StockCheck_Helper</class>
|
63 |
</stockcheck>
|
64 |
</helpers>
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
<adminhtml>
|
68 |
<acl>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @category Sitewards
|
6 |
+
* @package Sitewards_StockCheck
|
7 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
<config>
|
11 |
<modules>
|
12 |
<Sitewards_StockCheck>
|
13 |
+
<version>1.0.1</version>
|
14 |
</Sitewards_StockCheck>
|
15 |
</modules>
|
16 |
|
23 |
</stockcheck_group>
|
24 |
<stockcheck_img>
|
25 |
<stock_green_id>1</stock_green_id>
|
26 |
+
<stock_green_text>Item is in stock.</stock_green_text>
|
27 |
+
<stock_green_hover>This item is in stock and ready to ship.</stock_green_hover>
|
28 |
<stock_green_img>/images/stock_green.gif</stock_green_img>
|
29 |
<stock_yellow_id>2</stock_yellow_id>
|
30 |
+
<stock_yellow_text>Item is on order.</stock_yellow_text>
|
31 |
+
<stock_yellow_hover>Item is currently out of stock, but has been ordered. There should be no delivery delays</stock_yellow_hover>
|
32 |
<stock_yellow_img>/images/stock_yellow.gif</stock_yellow_img>
|
33 |
<stock_red_id>3</stock_red_id>
|
34 |
+
<stock_red_text>Item is currently out of stock.</stock_red_text>
|
35 |
+
<stock_red_hover>This item is currently out of stock and is on backorder in 2-4 working days</stock_red_hover>
|
36 |
<stock_red_img>/images/stock_red.gif</stock_red_img>
|
37 |
<stock_off_id>4</stock_off_id>
|
38 |
+
<stock_off_text>Item is not a stock item.</stock_off_text>
|
39 |
+
<stock_off_hover>This article is not a stock item and will be replenished in about 2-4 days.</stock_off_hover>
|
40 |
<stock_off_img>/images/stock_off.gif</stock_off_img>
|
41 |
</stockcheck_img>
|
42 |
</stockcheck_config>
|
51 |
<frontName>StockCheck</frontName>
|
52 |
</args>
|
53 |
</Sitewards_StockCheck>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
</routers>
|
55 |
</frontend>
|
56 |
|
57 |
<global>
|
58 |
<models>
|
59 |
+
<stockcheck>
|
60 |
+
<class>Sitewards_StockCheck_Model</class>
|
61 |
+
</stockcheck>
|
62 |
<catalog>
|
63 |
<rewrite>
|
64 |
<product>Sitewards_StockCheck_Model_Product</product>
|
70 |
<class>Sitewards_StockCheck_Helper</class>
|
71 |
</stockcheck>
|
72 |
</helpers>
|
73 |
+
<events>
|
74 |
+
<core_block_abstract_to_html_before>
|
75 |
+
<observers>
|
76 |
+
<stockcheck_cart>
|
77 |
+
<class>stockcheck/cart_observer</class>
|
78 |
+
<method>onCoreBlockAbstractToHtmlBefore</method>
|
79 |
+
</stockcheck_cart>
|
80 |
+
</observers>
|
81 |
+
</core_block_abstract_to_html_before>
|
82 |
+
</events>
|
83 |
+
</global>
|
84 |
|
85 |
<adminhtml>
|
86 |
<acl>
|
app/code/{local → community}/Sitewards/StockCheck/etc/system.xml
RENAMED
@@ -1,133 +1,177 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
<
|
31 |
-
<
|
32 |
-
<sort_order>
|
33 |
-
<show_in_default>1</show_in_default>
|
34 |
-
<show_in_website>1</show_in_website>
|
35 |
-
<show_in_store>1</show_in_store>
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
<
|
40 |
-
<
|
41 |
-
<
|
42 |
-
<
|
43 |
-
<
|
44 |
-
<
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
<
|
67 |
-
<
|
68 |
-
<
|
69 |
-
<
|
70 |
-
<
|
71 |
-
<
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
<
|
76 |
-
<
|
77 |
-
<
|
78 |
-
<
|
79 |
-
<
|
80 |
-
<
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
<
|
85 |
-
<
|
86 |
-
<
|
87 |
-
<
|
88 |
-
<
|
89 |
-
<
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
<
|
94 |
-
<
|
95 |
-
<
|
96 |
-
<
|
97 |
-
<
|
98 |
-
<
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
<
|
103 |
-
<
|
104 |
-
<
|
105 |
-
<
|
106 |
-
<
|
107 |
-
<
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
<
|
112 |
-
<
|
113 |
-
<
|
114 |
-
<
|
115 |
-
<
|
116 |
-
<
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
<
|
121 |
-
<
|
122 |
-
<
|
123 |
-
<
|
124 |
-
<
|
125 |
-
<
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
</config>
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @category Sitewards
|
6 |
+
* @package Sitewards_StockCheck
|
7 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<sections>
|
12 |
+
<stockcheck_config translate="label comment" module="stockcheck">
|
13 |
+
<tab>catalog</tab>
|
14 |
+
<label>Sitewards Stock Check</label>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>202</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<show_in_website>1</show_in_website>
|
19 |
+
<show_in_store>1</show_in_store>
|
20 |
+
<groups>
|
21 |
+
<stockcheck_group translate="label" module="stockcheck">
|
22 |
+
<label>Sitewards Stock Check</label>
|
23 |
+
<sort_order>1</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
+
<fields>
|
28 |
+
<disable_ext translate="label" module="stockcheck">
|
29 |
+
<label>Enable Sitewards Stock Check</label>
|
30 |
+
<frontend_type>select</frontend_type>
|
31 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
32 |
+
<sort_order>1</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
</disable_ext>
|
37 |
+
<product_identifier_name translate="label" module="stockcheck">
|
38 |
+
<label>Product Identifier</label>
|
39 |
+
<frontend_type>text</frontend_type>
|
40 |
+
<sort_order>2</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
<comment><![CDATA[Attribute on which to identify your products]]></comment>
|
45 |
+
</product_identifier_name>
|
46 |
+
<helper_name translate="label" module="stockcheck">
|
47 |
+
<label>Helper Name</label>
|
48 |
+
<frontend_type>text</frontend_type>
|
49 |
+
<sort_order>3</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
<comment><![CDATA[Allows you to specify a custom helper class outside of the pricecheck extension]]></comment>
|
54 |
+
</helper_name>
|
55 |
+
</fields>
|
56 |
+
</stockcheck_group>
|
57 |
+
<stockcheck_img translate="label" module="stockcheck">
|
58 |
+
<label>Sitewards Stock Check Images</label>
|
59 |
+
<sort_order>2</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>1</show_in_store>
|
63 |
+
<fields>
|
64 |
+
<stock_green_text translate="label" module="stockcheck">
|
65 |
+
<label>Stock Green Text</label>
|
66 |
+
<frontend_type>text</frontend_type>
|
67 |
+
<sort_order>1</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>1</show_in_store>
|
71 |
+
<comment><![CDATA[This is the alt text for the image]]></comment>
|
72 |
+
</stock_green_text>
|
73 |
+
<stock_green_hover translate="label" module="stockcheck">
|
74 |
+
<label>Stock Green Hover Text</label>
|
75 |
+
<frontend_type>text</frontend_type>
|
76 |
+
<sort_order>2</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>1</show_in_website>
|
79 |
+
<show_in_store>1</show_in_store>
|
80 |
+
<comment><![CDATA[This is the text that will appear through a JavaScript pop up]]></comment>
|
81 |
+
</stock_green_hover>
|
82 |
+
<stock_green_img translate="label" module="stockcheck">
|
83 |
+
<label>Stock Green Image</label>
|
84 |
+
<frontend_type>text</frontend_type>
|
85 |
+
<sort_order>3</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>1</show_in_store>
|
89 |
+
<comment><![CDATA[This is the path to the image e.g. /images/stock_green.gif]]></comment>
|
90 |
+
</stock_green_img>
|
91 |
+
<stock_yellow_text translate="label" module="stockcheck">
|
92 |
+
<label>Stock Yellow Text</label>
|
93 |
+
<frontend_type>text</frontend_type>
|
94 |
+
<sort_order>4</sort_order>
|
95 |
+
<show_in_default>1</show_in_default>
|
96 |
+
<show_in_website>1</show_in_website>
|
97 |
+
<show_in_store>1</show_in_store>
|
98 |
+
<comment><![CDATA[This is the alt text for the image]]></comment>
|
99 |
+
</stock_yellow_text>
|
100 |
+
<stock_yellow_hover translate="label" module="stockcheck">
|
101 |
+
<label>Stock Yellow Hover Text</label>
|
102 |
+
<frontend_type>text</frontend_type>
|
103 |
+
<sort_order>5</sort_order>
|
104 |
+
<show_in_default>1</show_in_default>
|
105 |
+
<show_in_website>1</show_in_website>
|
106 |
+
<show_in_store>1</show_in_store>
|
107 |
+
<comment><![CDATA[This is the text that will appear through a JavaScript pop up]]></comment>
|
108 |
+
</stock_yellow_hover>
|
109 |
+
<stock_yellow_img translate="label" module="stockcheck">
|
110 |
+
<label>Stock Yellow Image</label>
|
111 |
+
<frontend_type>text</frontend_type>
|
112 |
+
<sort_order>6</sort_order>
|
113 |
+
<show_in_default>1</show_in_default>
|
114 |
+
<show_in_website>1</show_in_website>
|
115 |
+
<show_in_store>1</show_in_store>
|
116 |
+
<comment><![CDATA[This is the path to the image e.g. /images/stock_yellow.gif]]></comment>
|
117 |
+
</stock_yellow_img>
|
118 |
+
<stock_red_text translate="label" module="stockcheck">
|
119 |
+
<label>Stock Red Text</label>
|
120 |
+
<frontend_type>text</frontend_type>
|
121 |
+
<sort_order>7</sort_order>
|
122 |
+
<show_in_default>1</show_in_default>
|
123 |
+
<show_in_website>1</show_in_website>
|
124 |
+
<show_in_store>1</show_in_store>
|
125 |
+
<comment><![CDATA[This is the alt text for the image]]></comment>
|
126 |
+
</stock_red_text>
|
127 |
+
<stock_red_hover translate="label" module="stockcheck">
|
128 |
+
<label>Stock Red Hover Text</label>
|
129 |
+
<frontend_type>text</frontend_type>
|
130 |
+
<sort_order>8</sort_order>
|
131 |
+
<show_in_default>1</show_in_default>
|
132 |
+
<show_in_website>1</show_in_website>
|
133 |
+
<show_in_store>1</show_in_store>
|
134 |
+
<comment><![CDATA[This is the text that will appear through a JavaScript pop up]]></comment>
|
135 |
+
</stock_red_hover>
|
136 |
+
<stock_red_img translate="label" module="stockcheck">
|
137 |
+
<label>Stock Red Image</label>
|
138 |
+
<frontend_type>text</frontend_type>
|
139 |
+
<sort_order>9</sort_order>
|
140 |
+
<show_in_default>1</show_in_default>
|
141 |
+
<show_in_website>1</show_in_website>
|
142 |
+
<show_in_store>1</show_in_store>
|
143 |
+
<comment><![CDATA[This is the path to the image e.g. /images/stock_red.gif]]></comment>
|
144 |
+
</stock_red_img>
|
145 |
+
<stock_off_text translate="label" module="stockcheck">
|
146 |
+
<label>Stock Off Text</label>
|
147 |
+
<frontend_type>text</frontend_type>
|
148 |
+
<sort_order>10</sort_order>
|
149 |
+
<show_in_default>1</show_in_default>
|
150 |
+
<show_in_website>1</show_in_website>
|
151 |
+
<show_in_store>1</show_in_store>
|
152 |
+
<comment><![CDATA[This is the alt text for the image]]></comment>
|
153 |
+
</stock_off_text>
|
154 |
+
<stock_off_hover translate="label" module="stockcheck">
|
155 |
+
<label>Stock Off Hover Text</label>
|
156 |
+
<frontend_type>text</frontend_type>
|
157 |
+
<sort_order>11</sort_order>
|
158 |
+
<show_in_default>1</show_in_default>
|
159 |
+
<show_in_website>1</show_in_website>
|
160 |
+
<show_in_store>1</show_in_store>
|
161 |
+
<comment><![CDATA[This is the text that will appear through a JavaScript pop up]]></comment>
|
162 |
+
</stock_off_hover>
|
163 |
+
<stock_off_img translate="label" module="stockcheck">
|
164 |
+
<label>Stock Off Image</label>
|
165 |
+
<frontend_type>text</frontend_type>
|
166 |
+
<sort_order>8</sort_order>
|
167 |
+
<show_in_default>1</show_in_default>
|
168 |
+
<show_in_website>1</show_in_website>
|
169 |
+
<show_in_store>1</show_in_store>
|
170 |
+
<comment><![CDATA[This is the path to the image e.g. /images/stock_off.gif]]></comment>
|
171 |
+
</stock_off_img>
|
172 |
+
</fields>
|
173 |
+
</stockcheck_img>
|
174 |
+
</groups>
|
175 |
+
</stockcheck_config>
|
176 |
+
</sections>
|
177 |
</config>
|
app/code/local/Sitewards/StockCheck/Helper/Data.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* @category Mage
|
5 |
-
* @package Sitewards_StockCheck
|
6 |
-
* @copyright Copyright (c) 2011 Sitewards GmbH. (http://www.sitewards.com)
|
7 |
-
* @license OSL
|
8 |
-
* @author David Manners <david.manners@sitewards.com>
|
9 |
-
* @version 1.0.0
|
10 |
-
*
|
11 |
-
* This class is used to help the Sitewards_StockCheck_Model_Product class and requires the following functions to be created
|
12 |
-
* getCustomQuantity,
|
13 |
-
* getStorageType,
|
14 |
-
* getProductsStockOrder
|
15 |
-
*/
|
16 |
-
class Sitewards_StockCheck_Helper_Data extends Mage_Core_Helper_Abstract {
|
17 |
-
protected $intStockGreenId;
|
18 |
-
protected $intStockYellowId;
|
19 |
-
protected $intStockRedId;
|
20 |
-
protected $intStockOffId;
|
21 |
-
|
22 |
-
public function __construct() {
|
23 |
-
$this->intStockGreenId = Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_id');
|
24 |
-
$this->intStockYellowId = Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_id');
|
25 |
-
$this->intStockRedId = Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_id');
|
26 |
-
$this->intStockOffId = Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_off_id');
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
*
|
31 |
-
* @param int|string $mxdProductSku unique identifier for a product - defaults to Magento ProductId
|
32 |
-
* @return int real time stock level
|
33 |
-
*/
|
34 |
-
public function getCustomQuantity($mxdProductSku) {
|
35 |
-
Mage::throwException('StockCheck extension not correctly setup. Please complete the function getCustomQuantity in the helper '.get_class());
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
*
|
40 |
-
* @param int|string $mxdProductSku unique identifier for a product - defaults to Magento ProductId
|
41 |
-
* @return int constant related to real time stock level
|
42 |
-
*/
|
43 |
-
public function getStorageType($mxdProductSku) {
|
44 |
-
Mage::throwException('StockCheck extension not correctly setup. Please complete the function getCustomQuantity in the helper '.get_class());
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
*
|
49 |
-
* @param int|string $mxdProductSku unique identifier for a product - defaults to Magento ProductId
|
50 |
-
* @return int current amount of stock taking into account the items on order
|
51 |
-
*/
|
52 |
-
public function getProductsStockOrder($mxdProductSku) {
|
53 |
-
Mage::throwException('StockCheck extension not correctly setup. Please complete the function getProductsStockOrder in the helper '.get_class());
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sitewards/StockCheck/Model/Product.php
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* @category Mage
|
5 |
-
* @package Sitewards_StockCheck
|
6 |
-
* @copyright Copyright (c) 2011 Sitewards GmbH. (http://www.sitewards.com)
|
7 |
-
* @license OSL
|
8 |
-
* @author David Manners <david.manners@sitewards.com>
|
9 |
-
* @version 1.0.0
|
10 |
-
*
|
11 |
-
* This class is used to disable Magento´s default Quantity calculations
|
12 |
-
*/
|
13 |
-
class Sitewards_StockCheck_Model_Product extends Mage_Catalog_Model_Product {
|
14 |
-
protected $strProductIdentifierName;
|
15 |
-
protected $strHelperName;
|
16 |
-
protected $bolExtensionActive;
|
17 |
-
|
18 |
-
public function __construct() {
|
19 |
-
$this->strProductIdentifierName = Mage::getStoreConfig('stockcheck_config/stockcheck_group/product_identifier_name');
|
20 |
-
$this->strHelperName = Mage::getStoreConfig('stockcheck_config/stockcheck_group/helper_name');
|
21 |
-
$this->bolExtensionActive = Mage::getStoreConfig('stockcheck_config/stockcheck_group/disable_ext');
|
22 |
-
parent::__construct();
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
*
|
27 |
-
* @return int stock level from external source or Mage_Catalog_Model_Product
|
28 |
-
*/
|
29 |
-
public function getQty() {
|
30 |
-
if($this->bolExtensionActive == true) {
|
31 |
-
$strProductIdentifierValue = $this->_getData($this->strProductIdentifierName);
|
32 |
-
|
33 |
-
if(method_exists(Mage::Helper($this->strHelperName), 'getCustomQuantity') == false) {
|
34 |
-
Mage::throwException('StockCheck extension not correctly setup. Please create the function getCustomQuantity in the helper '.$this->strHelperName);
|
35 |
-
} else {
|
36 |
-
$intCustomQty = Mage::Helper($this->strHelperName)->getCustomQuantity($strProductIdentifierValue);
|
37 |
-
if(!is_null($intCustomQty)) {
|
38 |
-
return $intCustomQty;
|
39 |
-
} else {
|
40 |
-
parent::getQty();
|
41 |
-
}
|
42 |
-
}
|
43 |
-
} else {
|
44 |
-
parent::getQty();
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
*
|
50 |
-
* @param int $intQuantity requested level of quantity for a product - defaults to 1
|
51 |
-
* @return array contianing the source and alt text of stock light
|
52 |
-
*/
|
53 |
-
public function getStockAsLight($intQuantity = 1) {
|
54 |
-
if($this->bolExtensionActive != true) {
|
55 |
-
return;
|
56 |
-
}
|
57 |
-
$strProductIdentifierValue = $this->_getData($this->strProductIdentifierName);
|
58 |
-
|
59 |
-
if(method_exists(Mage::Helper($this->strHelperName), 'getStorageType') == false) {
|
60 |
-
Mage::throwException('StockCheck extension not correctly setup. Please create the function getStorageType in the helper '.$this->strHelperName);
|
61 |
-
} elseif(method_exists(Mage::Helper($this->strHelperName), 'getProductsStockOrder') == false) {
|
62 |
-
Mage::throwException('StockCheck extension not correctly setup. Please create the function getProductsStockOrder in the helper '.$this->strHelperName);
|
63 |
-
} else {
|
64 |
-
$intStorageTypeId = Mage::Helper($this->strHelperName)->getStorageType($strProductIdentifierValue, $intQuantity);
|
65 |
-
|
66 |
-
switch($intStorageTypeId) {
|
67 |
-
case Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_id'):
|
68 |
-
return array(
|
69 |
-
'source' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_img'),
|
70 |
-
'alt' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_green_text')
|
71 |
-
);
|
72 |
-
break;
|
73 |
-
|
74 |
-
case Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_id'):
|
75 |
-
return array(
|
76 |
-
'source' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_img'),
|
77 |
-
'alt' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_yellow_text')
|
78 |
-
);
|
79 |
-
break;
|
80 |
-
|
81 |
-
case Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_id'):
|
82 |
-
return array(
|
83 |
-
'source' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_img'),
|
84 |
-
'alt' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_red_text')
|
85 |
-
);
|
86 |
-
break;
|
87 |
-
|
88 |
-
default:
|
89 |
-
return array(
|
90 |
-
'source' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_off_img'),
|
91 |
-
'alt' => Mage::getStoreConfig('stockcheck_config/stockcheck_img/stock_off_text')
|
92 |
-
);
|
93 |
-
}
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Sitewards/StockCheck/controllers/CartController.php
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* @category Mage
|
5 |
-
* @package Sitewards_StockCheck
|
6 |
-
* @copyright Copyright (c) 2011 Sitewards GmbH. (http://www.sitewards.com)
|
7 |
-
* @license OSL
|
8 |
-
* @author David Manners <david.manners@sitewards.com>
|
9 |
-
* @version 1.0.0
|
10 |
-
*
|
11 |
-
* This class is used to override the Mage_Checkout_CartController and display an error message about stock levels
|
12 |
-
*/
|
13 |
-
|
14 |
-
require_once 'Mage/Checkout/controllers/CartController.php';
|
15 |
-
class Sitewards_StockCheck_CartController extends Mage_Checkout_CartController {
|
16 |
-
/**
|
17 |
-
*
|
18 |
-
* Override the cart indexAction functio to check for stock levels and display a message if required
|
19 |
-
*/
|
20 |
-
public function indexAction(){
|
21 |
-
$bolExtensionActive = Mage::getStoreConfig('stockcheck_config/stockcheck_group/disable_ext');
|
22 |
-
if($bolExtensionActive == true) {
|
23 |
-
$strProductIdentifierName = Mage::getStoreConfig('stockcheck_config/stockcheck_group/product_identifier_name');
|
24 |
-
$objCart = $this->_getCart();
|
25 |
-
foreach($this->_getCart()->getItems() as $objItem) {
|
26 |
-
$objProduct = $objItem->getProduct();
|
27 |
-
$strArtnr = $objProduct->getData($strProductIdentifierName);
|
28 |
-
if(empty($strArtnr)) {
|
29 |
-
$objProduct->load($objProduct->getId());
|
30 |
-
}
|
31 |
-
$intActualUnits = $objItem->getProduct()->getQty();
|
32 |
-
$intPurchasedUnits = $objItem->getQty();
|
33 |
-
$objMessageFactory = Mage::getSingleton('core/message');
|
34 |
-
if($intActualUnits == 0) {
|
35 |
-
$objMessage = $objMessageFactory->error(Mage::helper('checkout')->__('This item is currently out of stock and is on backorder in 2-4 working days', $intActualUnits, $intPurchasedUnits - $intActualUnits));
|
36 |
-
$objCart->getCheckoutSession()->addQuoteItemMessage($objItem->getId(), $objMessage);
|
37 |
-
} elseif($intPurchasedUnits > $intActualUnits) {
|
38 |
-
$objMessage = $objMessageFactory->error(Mage::helper('checkout')->__('We currently on have %d units in stock, the remaining %d units will be in stock in 2-4 working days', $intActualUnits, $intPurchasedUnits - $intActualUnits));
|
39 |
-
$objCart->getCheckoutSession()->addQuoteItemMessage($objItem->getId(), $objMessage);
|
40 |
-
}
|
41 |
-
}
|
42 |
-
}
|
43 |
-
parent::indexAction();
|
44 |
-
}
|
45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/etc/modules/Sitewards_StockCheck.xml
CHANGED
@@ -1,9 +1,13 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
|
4 |
-
<Sitewards_StockCheck>
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
9 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Sitewards_StockCheck>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Catalog />
|
9 |
+
<Mage_Checkout />
|
10 |
+
</depends>
|
11 |
+
</Sitewards_StockCheck>
|
12 |
+
</modules>
|
13 |
</config>
|
package.xml
CHANGED
@@ -1,19 +1,22 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Sitewards_StockCheck_Framework</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
-
<license
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>This extension provides an easy to use framework for overriding the standard Magento Product
|
10 |
-
<description>This extension is aimed at developers who want to load the
|
11 |
Coding is required but can be provided at a cost.</description>
|
12 |
-
<notes>
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
<
|
|
|
|
|
|
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Sitewards_StockCheck_Framework</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>This extension provides an easy to use framework for overriding the standard Magento Product price model.</summary>
|
10 |
+
<description>This extension is aimed at developers who want to load the price of a product in realtime from another source.
|
11 |
Coding is required but can be provided at a cost.</description>
|
12 |
+
<notes>Removed Mage_Checkout CartController rewrite.
|
13 |
+
Added interface for StockCheck helper.
|
14 |
+
Extension moved to community code pool.
|
15 |
+
</notes>
|
16 |
+
<authors><author><name>Sitewards Magento Team</name><user>sitewards</user><email>magento@sitewards.com</email></author></authors>
|
17 |
+
<date>2013-06-16</date>
|
18 |
+
<time>20:34:55</time>
|
19 |
+
<contents><target name="magecommunity"><dir name="Sitewards"><dir name="StockCheck"><dir name="Helper"><file name="Data.php" hash="3f3e587feeaf4c50b01f101b650348d2"/><file name="Interface.php" hash="4fee3d3d744a5a0064a422186aeade77"/></dir><dir name="Model"><dir name="Cart"><file name="Observer.php" hash="8a4cc7443759e231018bfb4c5cfc6a4c"/></dir><file name="Product.php" hash="c1f3f1baccc002eb64e8497c3d59ea05"/></dir><dir name="etc"><file name="config.xml" hash="450e0547fadba92f5e376348684fb13f"/><file name="system.xml" hash="6abe9d8385dbb26aa2ba3f064230fe24"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sitewards_StockCheck.xml" hash="4457e64cbf4b478fd6a45961f742936f"/></dir></target></contents>
|
20 |
<compatible/>
|
21 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
22 |
</package>
|