Skip to content

Commit

Permalink
Merge pull request #205 from magento-south/BUGS
Browse files Browse the repository at this point in the history
[South] Sprint 33
  • Loading branch information
slavvka committed Mar 31, 2015
2 parents 252c85f + b972c9a commit 54d2d3a
Show file tree
Hide file tree
Showing 81 changed files with 4,482 additions and 2,183 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<default>
<dev>
<template>
<minify_html>1</minify_html>
<minify_html>0</minify_html>
</template>
</dev>
<system>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
namespace Magento\Catalog\Model\Category\Attribute\Source;

use Magento\Cms\Model\Resource\Block\Grid\CollectionFactory;
use Magento\Cms\Model\Resource\Block\CollectionFactory;

/**
* Catalog category landing page attribute source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class Page extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
/**
* Block collection factory
*
* @var \Magento\Cms\Model\Resource\Block\Grid\CollectionFactory
* @var \Magento\Cms\Model\Resource\Block\CollectionFactory
*/
protected $_blockCollectionFactory;

/**
* Construct
*
* @param \Magento\Cms\Model\Resource\Block\Grid\CollectionFactory $blockCollectionFactory
* @param \Magento\Cms\Model\Resource\Block\CollectionFactory $blockCollectionFactory
*/
public function __construct(\Magento\Cms\Model\Resource\Block\Grid\CollectionFactory $blockCollectionFactory)
public function __construct(\Magento\Cms\Model\Resource\Block\CollectionFactory $blockCollectionFactory)
{
$this->_blockCollectionFactory = $blockCollectionFactory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private function getMockedBlockCollectionFactory()
{
$mockedCollection = $this->getMockedCollection();

$mockBuilder = $this->getMockBuilder('Magento\Cms\Model\Resource\Block\Grid\CollectionFactory');
$mockBuilder = $this->getMockBuilder('Magento\Cms\Model\Resource\Block\CollectionFactory');
$mock = $mockBuilder->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
Expand Down
57 changes: 52 additions & 5 deletions app/code/Magento/Checkout/Block/Cart/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Magento\Checkout\Block\Cart;

use Magento\Framework\View\Block\IdentityInterface;
use Magento\Store\Model\ScopeInterface;

/**
* Wishlist sidebar block
Expand All @@ -19,6 +20,7 @@ class Sidebar extends AbstractCart implements IdentityInterface
* Xml pah to chackout sidebar count value
*/
const XML_PATH_CHECKOUT_SIDEBAR_COUNT = 'checkout/sidebar/count';
const XML_PATH_CHECKOUT_SIDEBAR_DISPLAY = 'checkout/sidebar/display';

/**
* @var \Magento\Catalog\Model\Resource\Url
Expand Down Expand Up @@ -73,7 +75,7 @@ public function getItemCount()
if (is_null($count)) {
$count = $this->_scopeConfig->getValue(
self::XML_PATH_CHECKOUT_SIDEBAR_COUNT,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
ScopeInterface::SCOPE_STORE
);
$this->setData('item_count', $count);
}
Expand Down Expand Up @@ -161,14 +163,43 @@ public function isPossibleOnepageCheckout()
/**
* Get one page checkout page url
*
* @return bool
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
* @return string
*/
public function getCheckoutUrl()
{
return $this->getUrl('checkout/onepage');
}

/**
* Get shoppinc cart page url
*
* @return string
*/
public function getShoppingCartUrl()
{
return $this->getUrl('checkout/cart');
}

/**
* Get update cart item url
*
* @return string
*/
public function getUpdateItemQtyUrl()
{
return $this->getUrl('checkout/sidebar/updateItemQty');
}

/**
* Get remove cart item url
*
* @return string
*/
public function getRemoveItemUrl()
{
return $this->getUrl('checkout/sidebar/removeItem');
}

/**
* Define if Mini Shopping Cart Pop-Up Menu enabled
*
Expand All @@ -178,8 +209,8 @@ public function getCheckoutUrl()
public function getIsNeedToDisplaySideBar()
{
return (bool)$this->_scopeConfig->getValue(
'checkout/sidebar/display',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
self::XML_PATH_CHECKOUT_SIDEBAR_DISPLAY,
ScopeInterface::SCOPE_STORE
);
}

Expand Down Expand Up @@ -284,8 +315,24 @@ public function getIdentities()
return $identities;
}

/**
* Retrieve subtotal block html
*
* @return string
*/
public function getTotalsHtml()
{
return $this->getLayout()->getBlock('checkout.cart.minicart.totals')->toHtml();
}

/**
* Retrieve items qty text
*
* @param int $qty
* @return \Magento\Framework\Phrase
*/
public function getSummaryText($qty)
{
return ($qty == 1) ? __(' item') : __(' items');
}
}
98 changes: 98 additions & 0 deletions app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Controller\Sidebar;

use Magento\Checkout\Model\Sidebar;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Response\Http;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Json\Helper\Data;
use Magento\Framework\View\Result\PageFactory;
use Psr\Log\LoggerInterface;

class RemoveItem extends Action
{
/**
* @var Sidebar
*/
protected $sidebar;

/**
* @var LoggerInterface
*/
protected $logger;

/**
* @var Data
*/
protected $jsonHelper;

/**
* @var PageFactory
*/
protected $resultPageFactory;

/**
* @param Context $context
* @param Sidebar $sidebar
* @param LoggerInterface $logger
* @param Data $jsonHelper
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
Sidebar $sidebar,
LoggerInterface $logger,
Data $jsonHelper,
PageFactory $resultPageFactory
) {
$this->sidebar = $sidebar;
$this->logger = $logger;
$this->jsonHelper = $jsonHelper;
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}

/**
* @return $this
*/
public function execute()
{
$itemId = (int)$this->getRequest()->getParam('item_id');
try {
$this->sidebar->checkQuoteItem($itemId);
$this->sidebar->removeQuoteItem($itemId);
return $this->jsonResponse();
} catch (LocalizedException $e) {
return $this->jsonResponse($e->getMessage());
} catch (\Exception $e) {
$this->logger->critical($e);
return $this->jsonResponse($e->getMessage());
}
}

/**
* Compile JSON response
*
* @param string $error
* @return Http
*/
protected function jsonResponse($error = '')
{
$response = $this->sidebar->getResponseData($error);

if (empty($error)) {
$resultPage = $this->resultPageFactory->create();
$block = $resultPage->getLayout()->getBlock('minicart.content')->toHtml();
$response['content'] = $block;
}

return $this->getResponse()->representJson(
$this->jsonHelper->jsonEncode($response)
);
}
}
83 changes: 83 additions & 0 deletions app/code/Magento/Checkout/Controller/Sidebar/UpdateItemQty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Controller\Sidebar;

use Magento\Checkout\Model\Sidebar;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Response\Http;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Json\Helper\Data;
use Psr\Log\LoggerInterface;

class UpdateItemQty extends Action
{
/**
* @var Sidebar
*/
protected $sidebar;

/**
* @var LoggerInterface
*/
protected $logger;

/**
* @var Data
*/
protected $jsonHelper;

/**
* @param Context $context
* @param Sidebar $sidebar
* @param LoggerInterface $logger
* @param Data $jsonHelper
*/
public function __construct(
Context $context,
Sidebar $sidebar,
LoggerInterface $logger,
Data $jsonHelper
) {
$this->sidebar = $sidebar;
$this->logger = $logger;
$this->jsonHelper = $jsonHelper;
parent::__construct($context);
}

/**
* @return $this
*/
public function execute()
{
$itemId = (int)$this->getRequest()->getParam('item_id');
$itemQty = (int)$this->getRequest()->getParam('item_qty');

try {
$this->sidebar->checkQuoteItem($itemId);
$this->sidebar->updateQuoteItem($itemId, $itemQty);
return $this->jsonResponse();
} catch (LocalizedException $e) {
return $this->jsonResponse($e->getMessage());
} catch (\Exception $e) {
$this->logger->critical($e);
return $this->jsonResponse($e->getMessage());
}
}

/**
* Compile JSON response
*
* @param string $error
* @return Http
*/
protected function jsonResponse($error = '')
{
return $this->getResponse()->representJson(
$this->jsonHelper->jsonEncode($this->sidebar->getResponseData($error))
);
}
}
4 changes: 3 additions & 1 deletion app/code/Magento/Checkout/Model/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ protected function reinitializeState()
{
$quote = $this->getQuote()->setCheckoutMethod('');
$this->_checkoutSession->setCartWasUpdated(true);
// TODO: Move this logic to Multishipping module as plug-in.
// reset for multiple address checkout
if ($this->_checkoutSession->getCheckoutState() !== Session::CHECKOUT_STATE_BEGIN) {
if ($this->_checkoutSession->getCheckoutState() !== Session::CHECKOUT_STATE_BEGIN
&& $this->_checkoutSession->getCheckoutState() !== null) {
$quote->removeAllAddresses()->removePayment();
$this->_checkoutSession->resetCheckout();
}
Expand Down
Loading

0 comments on commit 54d2d3a

Please sign in to comment.