当前位置: 首页>>代码示例>>PHP>>正文


PHP Api\GroupManagementInterface类代码示例

本文整理汇总了PHP中Magento\Customer\Api\GroupManagementInterface的典型用法代码示例。如果您正苦于以下问题:PHP GroupManagementInterface类的具体用法?PHP GroupManagementInterface怎么用?PHP GroupManagementInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GroupManagementInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)->getMockForAbstractClass();
     $this->groupRepositoryMock = $this->getMockBuilder(GroupRepositoryInterface::class)->getMockForAbstractClass();
     $this->groupManagementMock = $this->getMockBuilder(GroupManagementInterface::class)->getMockForAbstractClass();
     $this->searchCriteriaBuilderMock = $this->getMockBuilder(SearchCriteriaBuilder::class)->disableOriginalConstructor()->getMock();
     $this->moduleManagerMock = $this->getMockBuilder(ModuleManager::class)->disableOriginalConstructor()->getMock();
     $this->directoryHelperMock = $this->getMockBuilder(DirectoryHelper::class)->disableOriginalConstructor()->getMock();
     $this->productResourceMock = $this->getMockBuilder(ProductResource::class)->disableOriginalConstructor()->getMock();
     $this->attributeMock = $this->getMockBuilder(Attribute::class)->disableOriginalConstructor()->getMock();
     $this->customerGroupMock = $this->getMockBuilder(CustomerGroupInterface::class)->getMockForAbstractClass();
     $this->groupManagementMock->expects($this->any())->method('getAllCustomersGroup')->willReturn($this->customerGroupMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:AdvancedPricingTest.php

示例2: setUp

 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->product = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product');
     $this->tpFactory = $this->getMockForAbstractClass('Magento\\Catalog\\Api\\Data\\ProductTierPriceInterfaceFactory', [], '', false, true, true, ['create']);
     $this->websiteMock = $this->getMock('Magento\\Store\\Model\\Website', ['getId'], [], '', false);
     $storeMangerMock = $this->getMockForAbstractClass('Magento\\Store\\Model\\StoreManagerInterface', [], '', false, true, true, ['getWebsite']);
     $storeMangerMock->expects($this->any())->method('getWebsite')->will($this->returnValue($this->websiteMock));
     $this->scopeConfigMock = $this->getMockForAbstractClass('Magento\\Framework\\App\\Config\\ScopeConfigInterface', [], '', false, true, true, ['getValue']);
     $group = $this->getMock('\\Magento\\Customer\\Model\\Data\\Group', [], [], '', false);
     $group->expects($this->any())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL);
     $this->groupManagementMock = $this->getMock('Magento\\Customer\\Api\\GroupManagementInterface', [], [], '', false);
     $this->groupManagementMock->expects($this->any())->method('getAllCustomersGroup')->will($this->returnValue($group));
     $this->model = $this->objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\Type\\Price', ['tierPriceFactory' => $this->tpFactory, 'config' => $this->scopeConfigMock, 'storeManager' => $storeMangerMock, 'groupManagement' => $this->groupManagementMock]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:PriceTest.php

示例3: testGetSetCustomerGroupId

 public function testGetSetCustomerGroupId()
 {
     $this->assertEquals($this->groupManagement->getNotLoggedInGroup()->getId(), $this->_model->getCustomerGroupId());
     $customerGroupId = 123;
     $this->_model->setCustomerGroupId($customerGroupId);
     $this->assertEquals($customerGroupId, $this->_model->getCustomerGroupId());
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:7,代码来源:PriceTest.php

示例4: dispatch

 /**
  * Handle customer VAT number if needed on collect_totals_before event of quote address
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function dispatch(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Quote\Model\Quote\Address $quoteAddress */
     $quoteAddress = $observer->getQuoteAddress();
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $quoteAddress->getQuote();
     $customer = $quote->getCustomer();
     $storeId = $customer->getStoreId();
     if ($customer->getCustomAttribute('disable_auto_group_change') && $customer->getCustomAttribute('disable_auto_group_change')->getValue() || false == $this->vatValidator->isEnabled($quoteAddress, $storeId)) {
         return;
     }
     $customerCountryCode = $quoteAddress->getCountryId();
     $customerVatNumber = $quoteAddress->getVatId();
     $groupId = null;
     if (empty($customerVatNumber) || false == $this->customerVat->isCountryInEU($customerCountryCode)) {
         $groupId = $customer->getId() ? $this->groupManagement->getDefaultGroup($storeId)->getId() : $this->groupManagement->getNotLoggedInGroup()->getId();
     } else {
         // Magento always has to emulate group even if customer uses default billing/shipping address
         $groupId = $this->customerVat->getCustomerGroupIdBasedOnVatNumber($customerCountryCode, $this->vatValidator->validate($quoteAddress, $storeId), $storeId);
     }
     if ($groupId) {
         $quoteAddress->setPrevQuoteCustomerGroupId($quote->getCustomerGroupId());
         $quote->setCustomerGroupId($groupId);
         $customer->setGroupId($groupId);
         $quote->setCustomer($customer);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:33,代码来源:CollectTotals.php

示例5: execute

 /**
  * Handle customer VAT number if needed on collect_totals_before event of quote address
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment */
     $shippingAssignment = $observer->getShippingAssignment();
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $observer->getQuote();
     /** @var \Magento\Quote\Model\Quote\Address $address */
     $address = $shippingAssignment->getShipping()->getAddress();
     $customer = $quote->getCustomer();
     $storeId = $customer->getStoreId();
     if ($customer->getDisableAutoGroupChange() || false == $this->vatValidator->isEnabled($address, $storeId)) {
         return;
     }
     $customerCountryCode = $address->getCountryId();
     $customerVatNumber = $address->getVatId();
     $groupId = null;
     if (empty($customerVatNumber) || false == $this->customerVat->isCountryInEU($customerCountryCode)) {
         $groupId = $customer->getId() ? $this->groupManagement->getDefaultGroup($storeId)->getId() : $this->groupManagement->getNotLoggedInGroup()->getId();
     } else {
         // Magento always has to emulate group even if customer uses default billing/shipping address
         $groupId = $this->customerVat->getCustomerGroupIdBasedOnVatNumber($customerCountryCode, $this->vatValidator->validate($address, $storeId), $storeId);
     }
     if ($groupId) {
         $address->setPrevQuoteCustomerGroupId($quote->getCustomerGroupId());
         $quote->setCustomerGroupId($groupId);
         $customer->setGroupId($groupId);
         $quote->setCustomer($customer);
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:35,代码来源:CollectTotalsObserver.php

示例6: getCustomerGroupId

 /**
  * Getter for customer group id, return default group if not set
  *
  * @return int
  */
 public function getCustomerGroupId()
 {
     if ($this->customerGroupId === null) {
         return $this->groupManagement->getAllCustomersGroup()->getId();
     }
     return parent::getCustomerGroupId();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:12,代码来源:Item.php

示例7: toOptionArray

 /**
  * Retrieve customer groups as array
  *
  * @return array
  */
 public function toOptionArray()
 {
     if (!$this->_options) {
         $groups = $this->_groupManagement->getLoggedInGroups();
         $this->_options = $this->_converter->toOptionArray($groups, 'id', 'code');
     }
     return $this->_options;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Multiselect.php

示例8: toOptionArray

 /**
  * @return array
  */
 public function toOptionArray()
 {
     if (!$this->_options) {
         $groups = $this->_groupManagement->getLoggedInGroups();
         $this->_options = $this->_converter->toOptionArray($groups, 'id', 'code');
         array_unshift($this->_options, ['value' => '', 'label' => __('-- Please Select --')]);
     }
     return $this->_options;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:Group.php

示例9: testAddTierPriceData

 /**
  * @magentoDataFixture Magento/Catalog/Model/Resource/_files/product_simple.php
  */
 public function testAddTierPriceData()
 {
     $this->_collection->setFlag('tier_price_added', false);
     $this->_collection->addIdFilter(2);
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\Resource\\Product\\Collection', $this->_collection->addTierPriceData());
     $tierPrice = $this->_collection->getFirstItem()->getDataByKey('tier_price');
     $this->assertEquals($this->_groupManagement->getNotLoggedInGroup()->getId(), current($tierPrice)['cust_group']);
     $this->assertEquals($this->_groupManagement->getAllCustomersGroup()->getId(), next($tierPrice)['cust_group']);
     $this->assertTrue($this->_collection->getFlag('tier_price_added'));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:CollectionTest.php

示例10: testDeleteButtonNotExistInDefaultGroup

 /**
  * Verify that the Delete button does not exist for the default group.
  * @magentoAppIsolation enabled
  */
 public function testDeleteButtonNotExistInDefaultGroup()
 {
     $groupId = $this->groupManagement->getDefaultGroup(0)->getId();
     $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $groupId);
     $this->getRequest()->setParam('id', $groupId);
     /** @var $block Edit */
     $block = $this->layout->createBlock('Magento\\Customer\\Block\\Adminhtml\\Group\\Edit', 'block');
     $buttonsHtml = $block->getButtonsHtml();
     $this->assertNotContains('delete', $buttonsHtml);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:EditTest.php

示例11: _afterDelete

 /**
  * Method set default group id to the customers collection
  *
  * @param \Magento\Framework\Model\AbstractModel $group
  * @return $this
  */
 protected function _afterDelete(\Magento\Framework\Model\AbstractModel $group)
 {
     $customerCollection = $this->_createCustomersCollection()->addAttributeToFilter('group_id', $group->getId())->load();
     foreach ($customerCollection as $customer) {
         /** @var $customer \Magento\Customer\Model\Customer */
         $customer->load($customer->getId());
         $defaultGroupId = $this->_groupManagement->getDefaultGroup($customer->getStoreId())->getId();
         $customer->setGroupId($defaultGroupId);
         $customer->save();
     }
     return parent::_afterDelete($group);
 }
开发者ID:shazal,项目名称:magento2,代码行数:18,代码来源:Group.php

示例12: _construct

 /**
  * Update Save and Delete buttons. Remove Delete button if group can't be deleted.
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $this->_objectId = 'id';
     $this->_controller = 'adminhtml_group';
     $this->_blockGroup = 'Magento_Customer';
     $this->buttonList->update('save', 'label', __('Save Customer Group'));
     $this->buttonList->update('delete', 'label', __('Delete Customer Group'));
     $groupId = $this->coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
     if (!$groupId || $this->groupManagement->isReadonly($groupId)) {
         $this->buttonList->remove('delete');
     }
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:18,代码来源:Edit.php

示例13: testGetQuoteWithoutQuoteId

 /**
  * Run test getQuote method
  *
  * @return void
  */
 public function testGetQuoteWithoutQuoteId()
 {
     $quoteId = 22;
     $storeId = 10;
     $customerId = 66;
     $customerGroupId = 77;
     $this->quote->expects($this->any())->method('getQuoteId')->will($this->returnValue(null));
     $this->quote->expects($this->any())->method('setQuoteId')->with($quoteId);
     $cartInterfaceMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\CartInterface', ['getId', 'setId', 'getCreatedAt', 'setCreatedAt', 'getUpdatedAt', 'setUpdatedAt', 'getConvertedAt', 'setConvertedAt', 'getIsActive', 'setIsActive', 'getIsVirtual', 'getItems', 'setItems', 'getItemsCount', 'setItemsCount', 'getItemsQty', 'setItemsQty', 'getCustomer', 'setCustomer', 'getBillingAddress', 'setBillingAddress', 'getReservedOrderId', 'setReservedOrderId', 'getOrigOrderId', 'setOrigOrderId', 'getCurrency', 'setCurrency', 'getCustomerIsGuest', 'setCustomerIsGuest', 'getCustomerNote', 'setCustomerNote', 'getCustomerNoteNotify', 'setCustomerNoteNotify', 'getCustomerTaxClassId', 'setCustomerTaxClassId', 'getStoreId', 'setStoreId', 'getExtensionAttributes', 'setExtensionAttributes', 'setIgnoreOldQty', 'setIsSuperMode', 'setCustomerGroupId']);
     $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($cartInterfaceMock);
     $this->quote->expects($this->any())->method('getStoreId')->will($this->returnValue($storeId));
     $this->quote->expects($this->any())->method('getCustomerId')->will($this->returnValue($customerId));
     $cartInterfaceMock->expects($this->atLeastOnce())->method('getId')->willReturn($quoteId);
     $defaultGroup = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\GroupInterface')->getMock();
     $defaultGroup->expects($this->any())->method('getId')->will($this->returnValue($customerGroupId));
     $this->groupManagementMock->expects($this->any())->method('getDefaultGroup')->will($this->returnValue($defaultGroup));
     $dataCustomerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->disableOriginalConstructor()->getMock();
     $this->customerRepositoryMock->expects($this->once())->method('getById')->with($customerId)->willReturn($dataCustomerMock);
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', ['setStoreId', 'setCustomerGroupId', 'setIsActive', 'assignCustomer', 'setIgnoreOldQty', 'setIsSuperMode', '__wakeup'], [], '', false);
     $this->quoteRepositoryMock->expects($this->once())->method('get')->willReturn($quoteMock);
     $cartInterfaceMock->expects($this->once())->method('setCustomerGroupId')->with($customerGroupId)->will($this->returnSelf());
     $quoteMock->expects($this->once())->method('assignCustomer')->with($dataCustomerMock);
     $quoteMock->expects($this->once())->method('setIgnoreOldQty')->with(true);
     $quoteMock->expects($this->once())->method('setIsSuperMode')->with(true);
     $this->assertEquals($quoteMock, $this->quote->getQuote());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:31,代码来源:QuoteTest.php

示例14: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Product $product
  * @param Entry $entry
  * @return Entry
  */
 public function convertAttribute($product, $entry)
 {
     $product->setWebsiteId($this->_storeManager->getStore($product->getStoreId())->getWebsiteId());
     $defaultCustomerGroup = $this->groupManagement->getDefaultGroup($product->getStoreId());
     $product->setCustomerGroupId($defaultCustomerGroup->getId());
     /** @var \Magento\Store\Model\Store $store */
     $store = $this->_storeManager->getStore($product->getStoreId());
     $isSalePriceAllowed = $this->_config->getTargetCountry($product->getStoreId()) == 'US';
     // get tax settings
     $priceDisplayType = $this->_taxData->getPriceDisplayType($product->getStoreId());
     $inclTax = $priceDisplayType == Config::DISPLAY_TYPE_INCLUDING_TAX;
     $finalPrice = $this->_getFinalPrice($product, $store, $inclTax, $isSalePriceAllowed);
     // calculate price attribute value
     $price = $this->_getPrice($product, $store, $priceDisplayType, $inclTax, $isSalePriceAllowed);
     if ($isSalePriceAllowed) {
         // set sale_price and effective dates for it
         if ($price && $price - $finalPrice > 0.0001) {
             $this->_setAttributePrice($entry, $product, $price);
             $this->_setAttributePrice($entry, $product, $finalPrice, 'sale_price');
             $this->_setEffectiveDate($product, $entry);
         } else {
             $this->_setAttributePrice($entry, $product, $finalPrice);
             $entry->removeContentAttribute('sale_price_effective_date');
             $entry->removeContentAttribute('sale_price');
         }
         // calculate taxes
         $tax = $this->getGroupAttributeTax();
         if (!$inclTax && !is_null($tax)) {
             $tax->convertAttribute($product, $entry);
         }
     } else {
         $this->_setAttributePrice($entry, $product, $price);
     }
     return $entry;
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:42,代码来源:Price.php

示例15: extract

 /**
  * @param string $formCode
  * @param RequestInterface $request
  * @return \Magento\Customer\Api\Data\CustomerInterface
  */
 public function extract($formCode, RequestInterface $request)
 {
     $customerForm = $this->formFactory->create('customer', $formCode);
     $customerData = $customerForm->extractData($request);
     $allowedAttributes = $customerForm->getAllowedAttributes();
     $isGroupIdEmpty = isset($allowedAttributes['group_id']);
     $customerDataObject = $this->customerFactory->create();
     $this->dataObjectHelper->populateWithArray($customerDataObject, $customerData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     $store = $this->storeManager->getStore();
     if ($isGroupIdEmpty) {
         $customerDataObject->setGroupId($this->customerGroupManagement->getDefaultGroup($store->getId())->getId());
     }
     $customerDataObject->setWebsiteId($store->getWebsiteId());
     $customerDataObject->setStoreId($store->getId());
     return $customerDataObject;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:CustomerExtractor.php


注:本文中的Magento\Customer\Api\GroupManagementInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。