init
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Stemcell\Customer\Block\Account;
|
||||
|
||||
class Forgotpassword extends \Magento\Customer\Block\Account\Forgotpassword
|
||||
{
|
||||
/**
|
||||
* Get config
|
||||
*
|
||||
* @param string $path
|
||||
* @return string|null
|
||||
*/
|
||||
public function getConfig($path)
|
||||
{
|
||||
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Customer\Block\Address;
|
||||
|
||||
use Magento\Customer\Api\AddressRepositoryInterface;
|
||||
use Magento\Customer\Api\CustomerRepositoryInterface;
|
||||
use Magento\Customer\Block\Address\Grid;
|
||||
use Magento\Customer\Helper\Session\CurrentCustomer;
|
||||
use Magento\Customer\Model\Address\Config;
|
||||
use Magento\Customer\Model\Address\Mapper;
|
||||
use Magento\Customer\Model\ResourceModel\Address\Collection;
|
||||
use Magento\Customer\Model\ResourceModel\Address\CollectionFactory;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Magento\Theme\Block\Html\Pager;
|
||||
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
class Book extends \Magento\Customer\Block\Address\Book
|
||||
{
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $addressCollection;
|
||||
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
protected CollectionFactory $addressCollectionFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
AddressRepositoryInterface $addressRepository,
|
||||
CurrentCustomer $currentCustomer,
|
||||
Config $addressConfig,
|
||||
Mapper $addressMapper,
|
||||
CollectionFactory $addressCollectionFactory,
|
||||
CustomerRepositoryInterface $customerRepository = null,
|
||||
array $data = [],
|
||||
Grid $addressesGrid = null
|
||||
) {
|
||||
parent::__construct(
|
||||
$context,
|
||||
$customerRepository,
|
||||
$addressRepository,
|
||||
$currentCustomer,
|
||||
$addressConfig,
|
||||
$addressMapper,
|
||||
$data,
|
||||
$addressesGrid
|
||||
);
|
||||
$this->addressCollectionFactory = $addressCollectionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
protected function _prepareLayout(): Book
|
||||
{
|
||||
parent::_prepareLayout();
|
||||
$pager = $this->getChildBlock('pager');
|
||||
if ($pager===false) {
|
||||
$pager = $this->getLayout()->createBlock(Pager::class, 'customer.addresses.pager');
|
||||
$this->setChild('pager', $pager);
|
||||
}
|
||||
$pager->setCollection($this->getAddressCollection());
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customer addresses collection.
|
||||
*
|
||||
* Filters collection by customer id
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getAddressCollection(): Collection
|
||||
{
|
||||
if (null === $this->addressCollection) {
|
||||
if (null === $this->getCustomer()) {
|
||||
throw new NoSuchEntityException(__('Customer not logged in'));
|
||||
}
|
||||
$collection = $this->addressCollectionFactory->create();
|
||||
$collection->setOrder('entity_id', 'desc');
|
||||
|
||||
$collection->setCustomerFilter([$this->getCustomer()->getId()]);
|
||||
$this->addressCollection = $collection;
|
||||
}
|
||||
return $this->addressCollection;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace Stemcell\Customer\Block\Address;
|
||||
|
||||
use Magento\Framework\Api\AttributeInterface;
|
||||
|
||||
class Edit extends \Magento\Customer\Block\Address\Edit
|
||||
{
|
||||
public function getCustomAttributeValue(String $attributeCode) {
|
||||
|
||||
$attribute = $this->getAddress()->getCustomAttribute($attributeCode);
|
||||
|
||||
return $attribute instanceof AttributeInterface? $attribute->getValue():'';
|
||||
}
|
||||
|
||||
public function getRegionId()
|
||||
{
|
||||
return (int)$this->getAddress()->getRegionId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Customer\Block\Adminhtml\Edit;
|
||||
|
||||
use Magento\Customer\Block\Adminhtml\Edit\GenericButton;
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class SampleButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('下载模版文件'),
|
||||
'class' => 'save primary',
|
||||
'on_click' => sprintf("location.href = '%s';", $this->getSampleUrl()),
|
||||
'sort_order' => 90,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getSampleUrl()
|
||||
{
|
||||
return $this->getUrl('stemcell_customer/lab/sample');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Customer\Block\Adminhtml\Edit;
|
||||
|
||||
use Magento\Customer\Api\AccountManagementInterface;
|
||||
use Magento\Customer\Block\Adminhtml\Edit\GenericButton;
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
/**
|
||||
* Class SaveButton
|
||||
* @package Magento\Customer\Block\Adminhtml\Edit
|
||||
*/
|
||||
class SaveButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var AccountManagementInterface
|
||||
*/
|
||||
protected $customerAccountManagement;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Magento\Backend\Block\Widget\Context $context
|
||||
* @param \Magento\Framework\Registry $registry
|
||||
* @param AccountManagementInterface $customerAccountManagement
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\Block\Widget\Context $context,
|
||||
\Magento\Framework\Registry $registry,
|
||||
AccountManagementInterface $customerAccountManagement
|
||||
) {
|
||||
parent::__construct($context, $registry);
|
||||
$this->customerAccountManagement = $customerAccountManagement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('Save'),
|
||||
'class' => 'save primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => ['button' => ['event' => 'save']],
|
||||
'form-role' => 'save',
|
||||
],
|
||||
'sort_order' => 90,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Customer\Block\Adminhtml\Edit\Tab;
|
||||
|
||||
class View extends \Magento\Customer\Block\Adminhtml\Edit\Tab\View
|
||||
{
|
||||
public function canShowTab()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Customer\Block\Adminhtml\Salesperson;
|
||||
|
||||
use Magento\Customer\Block\Adminhtml\Edit\GenericButton;
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class SampleButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('下载模版文件'),
|
||||
'class' => 'save primary',
|
||||
'on_click' => sprintf("location.href = '%s';", $this->getSampleUrl()),
|
||||
'sort_order' => 90,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getSampleUrl()
|
||||
{
|
||||
return $this->getUrl('stemcell_customer/salesperson/sample');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Customer\Block;
|
||||
|
||||
use Magento\Customer\ViewModel\CookieSettings;
|
||||
use Magento\Customer\ViewModel\Customer\Auth;
|
||||
use Magento\Customer\ViewModel\Customer\JsonSerializer;
|
||||
|
||||
class CustomerData extends \Magento\Customer\Block\CustomerData
|
||||
{
|
||||
public function __construct(
|
||||
\Magento\Framework\View\Element\Template\Context $context,
|
||||
private Auth $auth,
|
||||
private JsonSerializer $jsonSerializer,
|
||||
private CookieSettings $cookieSettings,
|
||||
array $data = [],
|
||||
array $expirableSectionNames = []
|
||||
) {
|
||||
parent::__construct($context, $data, $expirableSectionNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Auth
|
||||
*/
|
||||
public function getAuth()
|
||||
{
|
||||
return $this->auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JsonSerializer
|
||||
*/
|
||||
public function getJsonSerializer()
|
||||
{
|
||||
return $this->jsonSerializer;
|
||||
}
|
||||
|
||||
public function getCookieSettings()
|
||||
{
|
||||
return $this->cookieSettings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace Stemcell\Customer\Block\Widget\Product;
|
||||
|
||||
class ProductsList extends \Magento\CatalogWidget\Block\Product\ProductsList
|
||||
{
|
||||
protected ?string $moreLink = null;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLinkAttributes(): ?string
|
||||
{
|
||||
if ($this->moreLink) {
|
||||
return $this->moreLink;
|
||||
}
|
||||
|
||||
$more = (string)$this->getData('more');
|
||||
if ($more && !\Zend_Uri::check($more)) {
|
||||
return $this->moreLink = $this->_urlBuilder->getUrl($more);
|
||||
}
|
||||
return $this->moreLink = $more;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user