From ea81889aeaa8990fac3b67f5ba5bf1d9197c33f1 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 12:08:12 +0200 Subject: [PATCH] create method for retriving last item added to cart --- core/lib/Thelia/Model/Cart.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 9a17e3160..7493546ae 100644 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -2,10 +2,12 @@ namespace Thelia\Model; +use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Model\Base\Cart as BaseCart; use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductPriceQuery; +use Thelia\Model\CartItemQuery; class Cart extends BaseCart { @@ -60,4 +62,13 @@ class Cart extends BaseCart return $cart; } + + public function getLastCartItemAdded() + { + $items = CartItemQuery::create() + ->filterByCartId($this->getId()) + ->orderByCreatedAt(Criteria::DESC) + ->findOne() + ; + } }