create method for retriving last item added to cart
This commit is contained in:
@@ -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()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user