本文整理汇总了PHP中MShop_Factory类的典型用法代码示例。如果您正苦于以下问题:PHP MShop_Factory类的具体用法?PHP MShop_Factory怎么用?PHP MShop_Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MShop_Factory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _getManager
/**
* 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;
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:12,代码来源:Default.php
示例2: update
/**
* 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;
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:40,代码来源:PropertyAdd.php
示例3: isAvailable
/**
* 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);
}
开发者ID:boettner-it,项目名称:aimeos-core,代码行数:34,代码来源:Weight.php
示例4: _getPropertyItems
/**
* 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);
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:13,代码来源:Default.php
示例5: saveItems
/**
* 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);
}
开发者ID:arcavias,项目名称:arcavias-core,代码行数:33,代码来源:Default.php
示例6: update
/**
* 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;
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:39,代码来源:Coupon.php
示例7: testProcess
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('[email protected]');
$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();
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:25,代码来源:DefaultTest.php
示例8: deleteItems
/**
* 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);
}
开发者ID:arcavias,项目名称:arcavias-core,代码行数:39,代码来源:Default.php
示例9: bootstrap
public static function bootstrap()
{
set_error_handler('TestHelper::errorHandler');
self::_getArcavias();
MShop_Factory::setCache(false);
Controller_ExtJS_Factory::setCache(false);
}
开发者ID:arcavias,项目名称:arcavias-core,代码行数:7,代码来源:TestHelper.php
示例10: update
/**
* 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;
}
开发者ID:arcavias,项目名称:arcavias-core,代码行数:41,代码来源:PropertyMatch.php
示例11: testSaveItemLabelContent
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'});
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:29,代码来源:DefaultTest.php
示例12: update
/**
* 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;
}
开发者ID:arcavias,项目名称:arcavias-core,代码行数:34,代码来源:BasketLimits.php
示例13: update
/**
* 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;
}
开发者ID:arcavias,项目名称:arcavias-core,代码行数:32,代码来源:Coupon.php
示例14: isAvailable
/**
* 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);
}
开发者ID:arcavias,项目名称:arcavias-core,代码行数:38,代码来源:OrderCheck.php
示例15: update
/**
* 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;
}
开发者ID:arcavias,项目名称:arcavias-core,代码行数:42,代码来源:ServicesUpdate.php
示例16: setUp
/**
* 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();
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:14,代码来源:DirectDebitTest.php
示例17: setUp
/**
* 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);
}
开发者ID:arcavias,项目名称:arcavias-core,代码行数:14,代码来源:DirectDebitTest.php
示例18: testRun
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();
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:8,代码来源:DefaultTest.php
示例19: testSet
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);
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:9,代码来源:DefaultTest.php
示例20: __construct
/**
* 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;
}
}
开发者ID:Bananamoon,项目名称:aimeos-core,代码行数:15,代码来源:Default.php
注:本文中的MShop_Factory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论