Example #1
0
 /**
  * Returns the manager the controller is using.
  *
  * @return MShop_Common_Manager_Interface Manager object
  */
 protected function _getManager()
 {
     if ($this->_manager === null) {
         $this->_manager = MShop_Factory::createManager($this->_getContext(), 'order/base/service/attribute');
     }
     return $this->_manager;
 }
Example #2
0
 /**
  * Returns the manager the controller is using.
  *
  * @return MShop_Common_Manager_Interface Manager object
  */
 protected function _getManager()
 {
     if ($this->_manager === null) {
         $this->_manager = MShop_Factory::createManager($this->_getContext(), 'media/list/type');
     }
     return $this->_manager;
 }
Example #3
0
 /**
  * Returns the manager the controller is using.
  *
  * @return MShop_Common_Manager_Interface Manager object
  */
 protected function _getManager()
 {
     if ($this->_manager === null) {
         $this->_manager = MShop_Factory::createManager($this->_getContext(), 'product/property/type');
     }
     return $this->_manager;
 }
Example #4
0
 /**
  * Receives a notification from a publisher object
  *
  * @param MW_Observer_Publisher_Interface $order Shop basket instance implementing publisher interface
  * @param string $action Name of the action to listen for
  * @param mixed $value Object or value changed in publisher
  * @throws MShop_Plugin_Exception in case of faulty configuration or parameters
  * @return bool true if attributes have been added successfully
  */
 public function update(MW_Observer_Publisher_Interface $order, $action, $value = null)
 {
     $class = 'MShop_Order_Item_Base_Interface';
     if (!$order instanceof $class) {
         throw new MShop_Plugin_Exception(sprintf('Object is not of required type "%1$s"', $class));
     }
     $class = 'MShop_Order_Item_Base_Product_Interface';
     if (!$value instanceof $class) {
         throw new MShop_Plugin_Exception(sprintf('Object is not of required type "%1$s"', $class));
     }
     $productManager = MShop_Factory::createManager($this->_getContext(), 'product');
     $config = $this->_getItem()->getConfig();
     foreach ($config as $key => $properties) {
         $keyElements = explode('.', $key);
         if ($keyElements[0] !== 'product' || count($keyElements) < 3) {
             throw new MShop_Plugin_Exception(sprintf('Configuration invalid'));
         }
         $productSubManager = $productManager->getSubManager($keyElements[1]);
         $search = $productSubManager->createSearch(true);
         $cond = array();
         $cond[] = $search->compare('==', $key, $value->getProductId());
         $cond[] = $search->getConditions();
         $search->setConditions($search->combine('&&', $cond));
         $result = $productSubManager->searchItems($search);
         foreach ($result as $item) {
             $attributes = $this->_addAttributes($item, $value, $properties);
             $value->setAttributes($attributes);
         }
     }
     return true;
 }
Example #5
0
 /**
  * Checks if the the basket weight is ok for the service provider.
  *
  * @param MShop_Order_Item_Base_Interface $basket Basket object
  *
  * @return boolean True if payment provider can be used, false if not
  */
 public function isAvailable(MShop_Order_Item_Base_Interface $basket)
 {
     $context = $this->_getContext();
     $basketWeight = 0;
     $basketItems = $basket->getProducts();
     foreach ($basketItems as $basketItem) {
         $prodId = $basketItem->getProductId();
         if (!isset($prodMap[$prodId])) {
             // basket can contain a product several times in different basket items
             $prodMap[$prodId] = 0.0;
         }
         $prodMap[$prodId] += $basketItem->getQuantity();
     }
     $propertyManager = MShop_Factory::createManager($context, 'product/property');
     $search = $propertyManager->createSearch(true);
     $expr = array($search->compare('==', 'product.property.productid', array_keys($prodMap)), $search->compare('==', 'product.property.type.code', 'package-weight'), $search->getConditions());
     $search->setConditions($search->combine('&&', $expr));
     $search->setSlice(0, 0x7fffffff);
     // if more than 100 products are in the basket
     foreach ($propertyManager->searchItems($search) as $property) {
         $basketWeight += (double) $property->getValue() * $prodMap[$property->getParentId()];
     }
     if ($this->_checkWeightScale($basketWeight) === false) {
         return false;
     }
     return $this->_getProvider()->isAvailable($basket);
 }
Example #6
0
 /**
  * Returns the manager the controller is using.
  *
  * @return MShop_Common_Manager_Interface Manager object
  */
 protected function _getManager()
 {
     if ($this->_manager === null) {
         $this->_manager = MShop_Factory::createManager($this->_getContext(), 'supplier');
     }
     return $this->_manager;
 }
Example #7
0
 /**
  * Returns the product properties for the given product ID
  *
  * @param string $prodid Unique product ID
  * @return array Associative list of product property items
  */
 protected function _getPropertyItems($prodid)
 {
     $manager = MShop_Factory::createManager($this->_getContext(), 'product/property');
     $search = $manager->createSearch();
     $search->setConditions($search->compare('==', 'product.property.parentid', $prodid));
     return $manager->searchItems($search);
 }
Example #8
0
 /**
  * Creates a new list item or updates an existing one or a list thereof.
  *
  * @param stdClass $params Associative array containing the item properties
  */
 public function saveItems(stdClass $params)
 {
     $this->_checkParams($params, array('site', 'items'));
     $this->_setLocale($params->site);
     $ids = $refIds = $domains = array();
     $items = !is_array($params->items) ? array($params->items) : $params->items;
     foreach ($items as $entry) {
         $item = $this->_createItem((array) $entry);
         $this->_manager->saveItem($item);
         $domains[$item->getDomain()] = true;
         $refIds[] = $item->getRefId();
         $ids[] = $item->getId();
     }
     if (isset($domains['product'])) {
         $context = $this->_getContext();
         $productManager = MShop_Factory::createManager($context, 'product');
         $search = $productManager->createSearch();
         $search->setConditions($search->compare('==', 'product.id', $refIds));
         $search->setSlice(0, count($refIds));
         $indexManager = MShop_Factory::createManager($context, 'catalog/index');
         $indexManager->rebuildIndex($productManager->searchItems($search));
     }
     $search = $this->_manager->createSearch();
     $search->setConditions($search->compare('==', 'catalog.list.id', $ids));
     $search->setSlice(0, count($ids));
     $items = $this->_toArray($this->_manager->searchItems($search));
     return array('items' => !is_array($params->items) ? reset($items) : $items, 'success' => true);
 }
Example #9
0
 /**
  * Receives a notification from a publisher object
  *
  * @param MW_Observer_Publisher_Interface $order Shop basket instance implementing publisher interface
  * @param string $action Name of the action to listen for
  * @param mixed $value Object or value changed in publisher
  */
 public function update(MW_Observer_Publisher_Interface $order, $action, $value = null)
 {
     $class = 'MShop_Order_Item_Base_Interface';
     if (!$order instanceof $class) {
         throw new MShop_Plugin_Exception(sprintf('Object is not of required type "%1$s"', $class));
     }
     $notAvailable = array();
     if (self::$_lock === false) {
         self::$_lock = true;
         $couponManager = MShop_Factory::createManager($this->_getContext(), 'coupon');
         foreach ($order->getCoupons() as $code => $products) {
             $search = $couponManager->createSearch(true);
             $expr = array($search->compare('==', 'coupon.code.code', $code), $search->getConditions());
             $search->setConditions($search->combine('&&', $expr));
             $search->setSlice(0, 1);
             $results = $couponManager->searchItems($search);
             if (($couponItem = reset($results)) !== false) {
                 $couponProvider = $couponManager->getProvider($couponItem, $code);
                 $couponProvider->updateCoupon($order);
             } else {
                 $notAvailable[$code] = 'coupon.gone';
             }
         }
         self::$_lock = false;
     }
     if (count($notAvailable) > 0) {
         $codes = array('coupon' => $notAvailable);
         $msg = sprintf('Coupon in basket is not available any more');
         throw new MShop_Plugin_Provider_Exception($msg, -1, null, $codes);
     }
     return true;
 }
Example #10
0
 public function testProcess()
 {
     $type = MShop_Order_Item_Base_Address_Abstract::TYPE_PAYMENT;
     $manager = MShop_Customer_Manager_Factory::createManager($this->_context);
     $search = $manager->createSearch();
     $search->setSlice(0, 1);
     $result = $manager->searchItems($search);
     if (($customerItem = reset($result)) === false) {
         throw new Exception('No customer item found');
     }
     $addrItem = $customerItem->getPaymentAddress();
     $addrItem->setEmail('*****@*****.**');
     $basketCntl = Controller_Frontend_Basket_Factory::createController($this->_context);
     $basketCntl->setAddress($type, $addrItem);
     $view = TestHelper::getView();
     $view->orderBasket = $basketCntl->get();
     $this->_object->setView($view);
     $orderBaseStub = $this->getMockBuilder('MShop_Order_Manager_Base_Default')->setConstructorArgs(array($this->_context))->setMethods(array('saveItem'))->getMock();
     $customerStub = $this->getMockBuilder('MShop_Customer_Manager_Default')->setConstructorArgs(array($this->_context))->setMethods(array('saveItem'))->getMock();
     $orderBaseStub->expects($this->once())->method('saveItem');
     $customerStub->expects($this->once())->method('saveItem');
     MShop_Factory::injectManager($this->_context, 'customer', $customerStub);
     MShop_Factory::injectManager($this->_context, 'order/base', $orderBaseStub);
     $this->_object->process();
 }
Example #11
0
 /**
  * Deletes an item or a list of items.
  *
  * @param stdClass $params Associative list of parameters
  * @return array Associative list with success value
  */
 public function deleteItems(stdClass $params)
 {
     $this->_checkParams($params, array('site', 'items'));
     $this->_setLocale($params->site);
     $idList = array();
     $ids = (array) $params->items;
     $context = $this->_getContext();
     $manager = $this->_getManager();
     $search = $manager->createSearch();
     $search->setConditions($search->compare('==', 'text.id', $ids));
     $search->setSlice(0, count($ids));
     foreach ($manager->searchItems($search) as $id => $item) {
         $idList[$item->getDomain()][] = $id;
     }
     $manager->deleteItems($ids);
     foreach ($idList as $domain => $domainIds) {
         $manager = MShop_Factory::createManager($context, $domain . '/list');
         $search = $manager->createSearch();
         $expr = array($search->compare('==', $domain . '.list.refid', $domainIds), $search->compare('==', $domain . '.list.domain', 'text'));
         $search->setConditions($search->combine('&&', $expr));
         $search->setSortations(array($search->sort('+', $domain . '.list.id')));
         $start = 0;
         do {
             $result = $manager->searchItems($search);
             $manager->deleteItems(array_keys($result));
             $count = count($result);
             $start += $count;
             $search->setSlice($start);
         } while ($count >= $search->getSliceSize());
     }
     $this->_clearCache($ids);
     return array('items' => $params->items, 'success' => true);
 }
Example #12
0
 /**
  * Returns the manager the controller is using.
  *
  * @return MShop_Common_Manager_Interface Manager object
  */
 protected function _getManager()
 {
     if ($this->_manager === null) {
         $this->_manager = MShop_Factory::createManager($this->_getContext(), 'product/stock/warehouse');
     }
     return $this->_manager;
 }
Example #13
0
 public static function bootstrap()
 {
     set_error_handler('TestHelper::errorHandler');
     self::_getArcavias();
     MShop_Factory::setCache(false);
     Controller_ExtJS_Factory::setCache(false);
 }
Example #14
0
 /**
  * Receives a notification from a publisher object
  *
  * @param MW_Observer_Publisher_Interface $order Shop basket instance implementing publisher interface
  * @param string $action Name of the action to listen for
  * @param mixed $value Object or value changed in publisher
  * @throws MShop_Plugin_Provider_Exception if checks fail
  * @return bool true if checks succeed
  */
 public function update(MW_Observer_Publisher_Interface $order, $action, $value = null)
 {
     $context = $this->_getContext();
     $context->getLogger()->log(__METHOD__ . ': event=' . $action, MW_Logger_Abstract::DEBUG);
     $class = 'MShop_Order_Item_Base_Interface';
     if (!$order instanceof $class) {
         throw new MShop_Plugin_Exception(sprintf('Object is not of required type "%1$s"', $class));
     }
     $class = 'MShop_Order_Item_Base_Product_Interface';
     if (!$value instanceof $class) {
         throw new MShop_Plugin_Exception(sprintf('Object is not of required type "%1$s"', $class));
     }
     $config = $this->_getItem()->getConfig();
     if ($config === array()) {
         return true;
     }
     $productManager = MShop_Factory::createManager($context, 'product');
     $criteria = $productManager->createSearch(true);
     $expr = array();
     $expr[] = $criteria->compare('==', 'product.id', $value->getProductId());
     $expr[] = $criteria->getConditions();
     foreach ($config as $property => $value) {
         $expr[] = $criteria->compare('==', $property, $value);
     }
     $criteria->setConditions($criteria->combine('&&', $expr));
     $result = $productManager->searchItems($criteria);
     if (reset($result) === false) {
         $code = array('product' => array_keys($config));
         throw new MShop_Plugin_Provider_Exception(sprintf('Product matching given properties not found'), -1, null, $code);
     }
     return true;
 }
Example #15
0
 /**
  * Returns the manager the controller is using.
  *
  * @return MShop_Common_Manager_Interface Manager object
  */
 protected function _getManager()
 {
     if ($this->_manager === null) {
         $this->_manager = MShop_Factory::createManager($this->_getContext(), 'attribute/list');
     }
     return $this->_manager;
 }
Example #16
0
 public function testSaveItemLabelContent()
 {
     $typeManager = MShop_Factory::createManager(TestHelper::getContext(), 'text/type');
     $criteria = $typeManager->createSearch();
     $criteria->setSlice(0, 1);
     $result = $typeManager->searchItems($criteria);
     if (($type = reset($result)) === false) {
         throw new Exception('No type item found');
     }
     $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('text.content' => 'controller test text', 'text.domain' => 'product', 'text.typeid' => $type->getId(), 'text.languageid' => 'de', 'text.status' => 1));
     $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => (object) array('==' => (object) array('text.content' => 'controller test text')))));
     $saved = $this->_object->saveItems($saveParams);
     $searched = $this->_object->searchItems($searchParams);
     $deleteParams = (object) array('site' => 'unittest', 'items' => $saved['items']->{'text.id'});
     $this->_object->deleteItems($deleteParams);
     $result = $this->_object->searchItems($searchParams);
     $this->assertInternalType('object', $saved['items']);
     $this->assertNotNull($saved['items']->{'text.id'});
     $this->assertEquals($saved['items']->{'text.id'}, $searched['items'][0]->{'text.id'});
     $this->assertEquals($saved['items']->{'text.content'}, $searched['items'][0]->{'text.content'});
     $this->assertEquals($saved['items']->{'text.domain'}, $searched['items'][0]->{'text.domain'});
     $this->assertEquals($saved['items']->{'text.typeid'}, $searched['items'][0]->{'text.typeid'});
     $this->assertEquals($saved['items']->{'text.content'}, $searched['items'][0]->{'text.label'});
     $this->assertEquals($saved['items']->{'text.languageid'}, $searched['items'][0]->{'text.languageid'});
     $this->assertEquals($saved['items']->{'text.status'}, $searched['items'][0]->{'text.status'});
     $this->assertEquals(1, count($searched['items']));
     $this->assertEquals(0, count($result['items']));
     $this->assertEquals('controller test text', $saved['items']->{'text.label'});
 }
Example #17
0
 /**
  * Returns the manager the controller is using.
  *
  * @return MShop_Common_Manager_Interface Manager object
  */
 protected function _getManager()
 {
     if ($this->_manager === null) {
         $this->_manager = MShop_Factory::createManager($this->_getContext(), 'customer/address');
     }
     return $this->_manager;
 }
Example #18
0
 /**
  * Receives a notification from a publisher object
  *
  * @param MW_Observer_Publisher_Interface $order Shop basket instance implementing publisher interface
  * @param string $action Name of the action to listen for
  * @param mixed $value Object or value changed in publisher
  * @throws MShop_Plugin_Provider_Exception if checks fail
  * @return bool true if checks succeed
  */
 public function update(MW_Observer_Publisher_Interface $order, $action, $value = null)
 {
     $context = $this->_getContext();
     $logger = $context->getLogger();
     $logger->log(__METHOD__ . ': event=' . $action, MW_Logger_Abstract::DEBUG);
     if ($context->getConfig()->get('mshop/plugin/provider/order/complete/disable', false)) {
         $logger->log(__METHOD__ . ': Is disabled', MW_Logger_Abstract::DEBUG);
         return true;
     }
     $class = 'MShop_Order_Item_Base_Interface';
     if (!$order instanceof $class) {
         throw new MShop_Plugin_Provider_Exception(sprintf('Object is not of required type "%1$s"', $class));
     }
     if (!($value & MShop_Order_Item_Base_Abstract::PARTS_PRODUCT)) {
         return true;
     }
     $count = 0;
     $sum = MShop_Factory::createManager($context, 'price')->createItem();
     foreach ($order->getProducts() as $product) {
         $sum->addItem($product->getPrice(), $product->getQuantity());
         $count += $product->getQuantity();
     }
     $this->_checkLimits($sum, $count);
     return true;
 }
Example #19
0
 /**
  * Receives a notification from a publisher object
  *
  * @param MW_Observer_Publisher_Interface $order Shop basket instance implementing publisher interface
  * @param string $action Name of the action to listen for
  * @param mixed $value Object or value changed in publisher
  */
 public function update(MW_Observer_Publisher_Interface $order, $action, $value = null)
 {
     $context = $this->_getContext();
     $context->getLogger()->log(__METHOD__ . ': event=' . $action, MW_Logger_Abstract::DEBUG);
     $class = 'MShop_Order_Item_Base_Interface';
     if (!$order instanceof $class) {
         $msg = 'Received notification from "%1$s" which doesn\'t implement "%2$s"';
         throw new MShop_Plugin_Exception(sprintf($msg, get_class($order), $class));
     }
     if (self::$_lock === false) {
         self::$_lock = true;
         $couponManager = MShop_Factory::createManager($context, 'coupon');
         $search = $couponManager->createSearch();
         foreach ($order->getCoupons() as $code => $products) {
             $search->setConditions($search->compare('==', 'coupon.code.code', $code));
             $results = $couponManager->searchItems($search);
             if (($couponItem = reset($results)) !== false) {
                 $couponProvider = $couponManager->getProvider($couponItem, $code);
                 $couponProvider->updateCoupon($order);
             }
         }
         self::$_lock = false;
     }
     return true;
 }
Example #20
0
 /**
  * Checks if payment provider can be used based on the basket content.
  * Checks for country, currency, address, scoring, etc. should be implemented in separate decorators
  *
  * @param MShop_Order_Item_Base_Interface $basket Basket object
  * @return boolean True if payment provider can be used, false if not
  */
 public function isAvailable(MShop_Order_Item_Base_Interface $basket)
 {
     $context = $this->_getContext();
     $config = $this->getServiceItem()->getConfig();
     if (($customerId = $context->getUserId()) === null) {
         return false;
     }
     $manager = MShop_Factory::createManager($context, 'order');
     if (isset($config['ordercheck.total-number-min'])) {
         $search = $manager->createSearch(true);
         $expr = array($search->compare('==', 'order.base.customerid', $customerId), $search->compare('>=', 'order.statuspayment', MShop_Order_Item_Abstract::PAY_AUTHORIZED), $search->getConditions());
         $search->setConditions($search->combine('&&', $expr));
         $search->setSlice(0, $config['ordercheck.total-number-min']);
         $result = $manager->searchItems($search);
         if (count($result) < (int) $config['ordercheck.total-number-min']) {
             return false;
         }
     }
     if (isset($config['ordercheck.limit-days-pending'])) {
         $time = time() - (int) $config['ordercheck.limit-days-pending'] * 86400;
         $search = $manager->createSearch(true);
         $expr = array($search->compare('==', 'order.base.customerid', $customerId), $search->compare('==', 'order.datepayment', date('Y-m-d H:i:s', $time)), $search->compare('==', 'order.statuspayment', MShop_Order_Item_Abstract::PAY_PENDING), $search->getConditions());
         $search->setConditions($search->combine('&&', $expr));
         $search->setSlice(0, 1);
         $result = $manager->searchItems($search);
         if (count($result) > 0) {
             return false;
         }
     }
     return $this->_getProvider()->isAvailable($basket);
 }
Example #21
0
 /**
  * Receives a notification from a publisher object
  *
  * @param MW_Observer_Publisher_Interface $order Shop basket instance implementing publisher interface
  * @param string $action Name of the action to listen for
  * @param mixed $value Object or value changed in publisher
  * @throws MShop_Plugin_Provider_Exception if checks fail
  * @return bool true if checks succeed
  */
 public function update(MW_Observer_Publisher_Interface $order, $action, $value = null)
 {
     $ids = array();
     $context = $this->_getContext();
     $services = $order->getServices();
     if (count($order->getProducts()) === 0) {
         $priceManager = MShop_Factory::createManager($context, 'price');
         foreach ($services as $type => $service) {
             $service->setPrice($priceManager->createItem());
         }
         return true;
     }
     foreach ($services as $type => $service) {
         $ids[$type] = $service->getServiceId();
     }
     $serviceManager = MShop_Factory::createManager($context, 'service');
     $search = $serviceManager->createSearch(true);
     $expr = array($search->compare('==', 'service.id', $ids), $search->getConditions());
     $search->setConditions($search->combine('&&', $expr));
     $result = $serviceManager->searchItems($search, array('price'));
     foreach ($services as $type => $service) {
         if (isset($result[$service->getServiceId()])) {
             $provider = $serviceManager->getProvider($result[$service->getServiceId()]);
             if ($provider->isAvailable($order)) {
                 $service->setPrice($provider->calcPrice($order));
                 $order->setService($service, $type);
                 continue;
             }
         }
         $order->deleteService($type);
     }
     return true;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $context = TestHelper::getContext();
     $this->_ordServItem = MShop_Factory::createManager($context, 'order/base/service')->createItem();
     $serviceItem = MShop_Factory::createManager($context, 'service')->createItem();
     $serviceItem->setCode('test');
     $this->_object = $this->getMockBuilder('MShop_Service_Provider_Payment_DirectDebit')->setMethods(array('_getOrder', '_getOrderBase', '_saveOrder', '_saveOrderBase'))->setConstructorArgs(array($context, $serviceItem))->getMock();
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $context = TestHelper::getContext();
     $this->_ordServItem = MShop_Factory::createManager($context, 'order/base/service')->createItem();
     $serviceItem = MShop_Factory::createManager($context, 'service')->createItem();
     $serviceItem->setCode('test');
     $this->_object = new MShop_Service_Provider_Payment_DirectDebit($context, $serviceItem);
 }
Example #24
0
 public function testRun()
 {
     $stub = $this->getMockBuilder('MShop_Product_Manager_List_Default')->setConstructorArgs(array($this->_context))->setMethods(array('deleteItems', 'saveItem'))->getMock();
     MShop_Factory::injectManager($this->_context, 'product/list', $stub);
     $stub->expects($this->atLeastOnce())->method('deleteItems');
     $stub->expects($this->atLeastOnce())->method('saveItem');
     $this->_object->run();
 }
Example #25
0
 public function testSet()
 {
     $item = MShop_Factory::createManager(TestHelper::getContext(), 'product/stock/warehouse')->createItem();
     $item->setCode('cache-test');
     $item->setId(1);
     $this->_object->set($item);
     $id = $this->_object->get('cache-test');
     $this->assertEquals($item->getId(), $id);
 }
Example #26
0
 /**
  * Initializes the object
  *
  * @param MShop_Context_Item_Interface $context Context object
  */
 public function __construct(MShop_Context_Item_Interface $context)
 {
     parent::__construct($context);
     $manager = MShop_Factory::createManager($context, 'product/stock/warehouse');
     $search = $manager->createSearch();
     $search->setSlice(0, 1000);
     foreach ($manager->searchItems($search) as $id => $item) {
         $this->_warehouses[$item->getCode()] = $id;
     }
 }
Example #27
0
 public function testSetConfigFE()
 {
     $item = MShop_Factory::createManager(TestHelper::getContext(), 'order/base/service')->createItem();
     $this->_object->setConfigFE($item, array('test.code' => 'abc', 'test.number' => 123));
     $this->assertEquals(2, count($item->getAttributes()));
     $this->assertEquals('abc', $item->getAttribute('test.code', 'delivery'));
     $this->assertEquals(123, $item->getAttribute('test.number', 'delivery'));
     $this->assertEquals('delivery', $item->getAttributeItem('test.code', 'delivery')->getType());
     $this->assertEquals('delivery', $item->getAttributeItem('test.number', 'delivery')->getType());
 }
Example #28
0
 /**
  * Returns the product for the given code.
  *
  * @param string $code Unique product code
  * @throws Exception If no product is found
  * @return MShop_Product_Item_Interface
  */
 protected function _getProductItem($code)
 {
     $manager = MShop_Factory::createManager($this->_context, 'product');
     $search = $manager->createSearch();
     $search->setConditions($search->compare('==', 'product.code', $code));
     $result = $manager->searchItems($search);
     if (($item = reset($result)) === false) {
         throw new Exception(sprintf('No product item with code "%1$s" found', $code));
     }
     return $item;
 }
Example #29
0
 public function testUpdate()
 {
     $context = TestHelper::getContext();
     $name = 'ControllerFrontendOrderUpdate';
     $context->getConfig()->set('classes/controller/common/order/name', $name);
     $orderCntlStub = $this->getMockBuilder('Controller_Common_Order_Default')->setMethods(array('update'))->setConstructorArgs(array($context))->getMock();
     Controller_Common_Order_Factory::injectController('Controller_Common_Order_' . $name, $orderCntlStub);
     $orderCntlStub->expects($this->once())->method('update');
     $object = new Controller_Frontend_Order_Default($context);
     $object->update(MShop_Factory::createManager($context, 'order')->createItem());
 }
Example #30
0
 /**
  * Returns the enabled site items which may be limited by the input arguments.
  *
  * @param \MShop_Context_Item_Interface $context Context item object
  * @param string|array $sites Unique site codes
  * @return \MShop_Locale_Item_Site_Interface[] List of site items
  */
 protected function getSiteItems(\MShop_Context_Item_Interface $context, $sites)
 {
     $manager = \MShop_Factory::createManager($context, 'locale/site');
     $search = $manager->createSearch();
     if (is_scalar($sites) && $sites != '') {
         $sites = explode(' ', $sites);
     }
     if (!empty($sites)) {
         $search->setConditions($search->compare('==', 'locale.site.code', $sites));
     }
     return $manager->searchItems($search);
 }