ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
<?php
namespace JR\NetSuite\Model\Config\Source;
class Category implements \Magento\Framework\Option\ArrayInterface
{
private $categoryFactory;
private $categoryCollectionFactory;
public function __construct(
\Magento\Catalog\Model\CategoryFactory $categoryFactory,
\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollectionFactory
) {
$this->categoryFactory = $categoryFactory;
$this->categoryCollectionFactory = $categoryCollectionFactory;
}
public function getCategoryCollection($isActive = true, $level = false, $sortBy = false, $pageSize = false)
{
$collection = $this->categoryCollectionFactory->create();
$collection->addAttributeToSelect('*');
// select only active categories
if ($isActive) {
$collection->addIsActiveFilter();
}
// select categories of certain level
if ($level) {
$collection->addLevelFilter($level);
}
// sort categories by some value
if ($sortBy) {
$collection->addOrderField($sortBy);
}
// select certain number of categories
if ($pageSize) {
$collection->setPageSize($pageSize);
}
return $collection;
}
public function toOptionArray()
{
$arr = $this->_toArray();
$ret = [];
foreach ($arr as $key => $value) {
$ret[] = [
'value' => $key,
'label' => $value
];
}
return $ret;
}
private function _toArray()
{
$categories = $this->getCategoryCollection(true, false, false, false);
$categoryList = [];
foreach ($categories as $category) {
$categoryList[$category->getEntityId()] = __($this->_getParentName($category->getPath()) . $category->getName());
}
return $categoryList;
}
private function _getParentName($path = '')
{
$parentName = '';
$rootCats = [1,2];
$catTree = explode("/", $path);
// Deleting category itself
array_pop($catTree);
if ($catTree && (count($catTree) > count($rootCats))) {
foreach ($catTree as $catId) {
if (!in_array($catId, $rootCats)) {
$category = $this->categoryFactory->create()->load($catId);
$categoryName = $category->getName();
$parentName .= $categoryName . ' -> ';
}
}
}
return $parentName;
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace JR\NetSuite\Model\Config\Source;
class CustomerGroup
{
protected $_customerGroupCollectionFactory;
public function __construct(
\Magento\Customer\Model\ResourceModel\Group\CollectionFactory $customerGroupCollectionFactory
) {
$this->_customerGroupCollectionFactory = $customerGroupCollectionFactory;
}
public function toOptionArray()
{
$customerGroups = $this->_customerGroupCollectionFactory->create();
$customerGroupArray = [];
foreach ($customerGroups as $customerGroup) {
$customerGroupArray[] = [
'value' => $customerGroup->getCode(),
'label' => $customerGroup->getCode()
];
}
return $customerGroupArray;
}
}
@@ -0,0 +1,72 @@
<?php
namespace JR\NetSuite\Model\Config\Source;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
use Magento\Framework\Data\OptionSourceInterface;
use Magento\InventoryApi\Api\SourceRepositoryInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
class InventorySource extends AbstractSource implements SourceInterface, OptionSourceInterface
{
protected $sourceRepository;
protected $searchCriteriaBuilder;
public function __construct(
SourceRepositoryInterface $sourceRepository,
SearchCriteriaBuilder $searchCriteriaBuilder
) {
$this->sourceRepository = $sourceRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
}
/**
* Retrieve option array
*
* @return string[]
*/
public function getOptionArray()
{
$searchCriteria = $this->searchCriteriaBuilder->create();
$sources = $this->sourceRepository->getList($searchCriteria)->getItems();
$options = [];
foreach ($sources as $source) {
$options[$source->getSourceCode()] = $source->getName();
}
return $options;
}
/**
* Get options
*
* @return array
*/
public function getAllOptions()
{
$searchCriteria = $this->searchCriteriaBuilder->create();
$sources = $this->sourceRepository->getList($searchCriteria)->getItems();
$options = [];
foreach ($sources as $source) {
$options[] = [
'value' => $source->getSourceCode(),
'label' => $source->getName()
];
}
return $options;
}
/**
* Retrieve option text by option value
*
* @return array
*/
public function toOptionArray()
{
return $this->getAllOptions();
}
}
+72
View File
@@ -0,0 +1,72 @@
<?php
namespace JR\NetSuite\Model\Config\Source;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
use Magento\Framework\Data\OptionSourceInterface;
/**
* Product status functionality model
*
* @api
* @since 100.0.2
*/
class IsActive extends AbstractSource implements SourceInterface, OptionSourceInterface
{
/**#@+
* Product Status values
*/
const STATUS_ENABLED = 1;
const STATUS_DISABLED = 0;
/**#@-*/
/**
* Retrieve Visible Status Ids
*
* @return int[]
*/
public function getVisibleStatusIds()
{
return [self::STATUS_ENABLED];
}
/**
* Retrieve Saleable Status Ids
* Default Product Enable status
*
* @return int[]
*/
public function getSaleableStatusIds()
{
return [self::STATUS_ENABLED];
}
/**
* Retrieve option array
*
* @return string[]
*/
public function getOptionArray()
{
return [self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled')];
}
/**
* Retrieve option array with empty value
*
* @return string[]
*/
public function getAllOptions()
{
$result = [];
foreach (self::getOptionArray() as $index => $value) {
$result[] = ['value' => $index, 'label' => $value];
}
return $result;
}
}
+84
View File
@@ -0,0 +1,84 @@
<?php
namespace JR\NetSuite\Model\Config\Source;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
use Magento\Framework\Data\OptionSourceInterface;
/**
* Product status functionality model
*
* @api
* @since 100.0.2
*/
class Status extends AbstractSource implements SourceInterface, OptionSourceInterface
{
/**#@+
* Product Status values
*/
const STATUS_PENDING = 'pending';
const STATUS_PROCESSING = 'processing';
const STATUS_SUCCESS = 'success';
const STATUS_FAILED = 'failed';
const STATUS_ERROR = 'error';
/**#@-*/
/**
* Retrieve Visible Status Ids
*
* @return string[]
*/
public function getVisibleStatusIds()
{
return [self::STATUS_SUCCESS];
}
/**
* Retrieve Saleable Status Ids
* Default Product Enable status
*
* @return string[]
*/
public function getSaleableStatusIds()
{
return [self::STATUS_SUCCESS];
}
/**
* Retrieve option array
*
* @return string[]
*/
public function getOptionArray()
{
return [
self::STATUS_PENDING => __('Pending'),
self::STATUS_ERROR => __('Error'),
self::STATUS_FAILED => __('Failed'),
self::STATUS_PROCESSING => __('Processing'),
self::STATUS_SUCCESS => __('Success'),
];
}
/**
* Retrieve option array with empty value
*
* @return string[]
*/
public function getAllOptions()
{
$result = [];
foreach (self::getOptionArray() as $index => $value) {
$result[] = ['value' => $index, 'label' => $value];
}
return $result;
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace JR\NetSuite\Model\Config\Source;
class Store
{
protected $_storeManager;
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->_storeManager = $storeManager;
}
public function toOptionArray()
{
$stores = $this->_storeManager->getStores();
$options = [];
foreach ($stores as $store) {
$options[] = [
'label' => $store->getName(),
'value' => $store->getId()
];
}
return $options;
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace JR\NetSuite\Model\Config\Source;
class Taxclass implements \Magento\Framework\Option\ArrayInterface
{
protected $taxClass;
public function __construct(
\Magento\Tax\Model\TaxClass\Source\Product $taxClass
) {
$this->taxClass = $taxClass;
}
/**
* @return array
*/
public function toOptionArray()
{
return $this->taxClass->getAllOptions();
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace JR\NetSuite\Model\Config\Source;
class Visibility implements \Magento\Framework\Option\ArrayInterface
{
protected $visibility;
public function __construct(
\Magento\Catalog\Model\Product\Visibility $visibility
) {
$this->visibility = $visibility;
}
/**
* @return array
*/
public function toOptionArray()
{
return $this->visibility->getOptionArray();
}
}