Skip to content

Commit

Permalink
Merge pull request #30 from philwinkle/master
Browse files Browse the repository at this point in the history
Avoid use of  superglobals, exit statements.
Good ones Phillip, thanks!
  • Loading branch information
wigman committed Sep 9, 2015
2 parents dc8b4fe + 0912600 commit b77cc5d
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<?php
class Wigman_AjaxSwatches_AjaxController extends Mage_Core_Controller_Front_Action {

protected $_request;

protected function _construct()
{
parent::_construct();
$this->_request = Mage::app()->getRequest()->getParams();
}

public function updateAction(){


if(!isset($_REQUEST['pid'])) { exit; }
if(!isset($this->_request['pid'])) { return; }

$pid = $_REQUEST['pid'];
$pid = $this->_request['pid'];

$_product = Mage::getModel('catalog/product')->load($pid);
//get Product
Expand Down Expand Up @@ -46,18 +54,18 @@ public function updateAction(){

public function getlistdataAction(){

if(!isset($_REQUEST['pids'])) { exit; }
if(!isset($this->_request['pids'])) { return; }

if (!Mage::helper('configurableswatches')->isEnabled()) { // check if functionality disabled
exit; // exit without loading swatch functionality
return; // return without loading swatch functionality
}

$pids = explode(',',$_REQUEST['pids']);
$pids = explode(',',$this->_request['pids']);

$response = $swatches = $jsons = array();
$this->loadLayout();

$viewMode = (isset($_REQUEST['viewMode']))? $_REQUEST['viewMode'] : 'grid';
$viewMode = (isset($this->_request['viewMode']))? $this->_request['viewMode'] : 'grid';
$keepFrame = ($viewMode == 'grid')? true : false;

foreach($pids as $pid){
Expand Down Expand Up @@ -93,7 +101,6 @@ public function getlistdataAction(){

$this->getResponse()->clearHeaders()->setHeader('Content-type','application/json',true);
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
return;
}

}

0 comments on commit b77cc5d

Please sign in to comment.