init
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface CellSortRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Save CellSort
|
||||
* @param \Stemcell\Catalog\Api\Data\CellSortInterface $cellSort
|
||||
* @return \Stemcell\Catalog\Api\Data\CellSortInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function save(
|
||||
\Stemcell\Catalog\Api\Data\CellSortInterface $cellSort
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve CellSort
|
||||
* @param int $cellsortId
|
||||
* @return \Stemcell\Catalog\Api\Data\CellSortInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function get($cellsortId);
|
||||
|
||||
/**
|
||||
* Retrieve CellSort matching the specified criteria.
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
* @return \Stemcell\Catalog\Api\Data\CellSortSearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete CellSort
|
||||
* @param \Stemcell\Catalog\Api\Data\CellSortInterface $cellSort
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function delete(
|
||||
\Stemcell\Catalog\Api\Data\CellSortInterface $cellSort
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete CellSort by ID
|
||||
* @param string $cellsortId
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function deleteById($cellsortId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface CellSubTypeRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Save CellSubType
|
||||
* @param \Stemcell\Catalog\Api\Data\CellSubTypeInterface $cellSubType
|
||||
* @return \Stemcell\Catalog\Api\Data\CellSubTypeInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function save(
|
||||
\Stemcell\Catalog\Api\Data\CellSubTypeInterface $cellSubType
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve CellSubType
|
||||
* @param string $cellsubtypeId
|
||||
* @return \Stemcell\Catalog\Api\Data\CellSubTypeInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function get($cellsubtypeId);
|
||||
|
||||
/**
|
||||
* Retrieve CellSubType matching the specified criteria.
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
* @return \Stemcell\Catalog\Api\Data\CellSubTypeSearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete CellSubType
|
||||
* @param \Stemcell\Catalog\Api\Data\CellSubTypeInterface $cellSubType
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function delete(
|
||||
\Stemcell\Catalog\Api\Data\CellSubTypeInterface $cellSubType
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete CellSubType by ID
|
||||
* @param string $cellsubtypeId
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function deleteById($cellsubtypeId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface CellTypeRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Save CellType
|
||||
* @param \Stemcell\Catalog\Api\Data\CellTypeInterface $cellType
|
||||
* @return \Stemcell\Catalog\Api\Data\CellTypeInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function save(
|
||||
\Stemcell\Catalog\Api\Data\CellTypeInterface $cellType
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve CellType
|
||||
* @param string $celltypeId
|
||||
* @return \Stemcell\Catalog\Api\Data\CellTypeInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function get($celltypeId);
|
||||
|
||||
/**
|
||||
* Retrieve CellType matching the specified criteria.
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
* @return \Stemcell\Catalog\Api\Data\CellTypeSearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete CellType
|
||||
* @param \Stemcell\Catalog\Api\Data\CellTypeInterface $cellType
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function delete(
|
||||
\Stemcell\Catalog\Api\Data\CellTypeInterface $cellType
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete CellType by ID
|
||||
* @param string $celltypeId
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function deleteById($celltypeId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface CryopreserveRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Save cryopreserve
|
||||
* @param \Stemcell\Catalog\Api\Data\CryopreserveInterface $cryopreserve
|
||||
* @return \Stemcell\Catalog\Api\Data\CryopreserveInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function save(
|
||||
\Stemcell\Catalog\Api\Data\CryopreserveInterface $cryopreserve
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve cryopreserve
|
||||
* @param string $cryopreserveId
|
||||
* @return \Stemcell\Catalog\Api\Data\CryopreserveInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function get($cryopreserveId);
|
||||
|
||||
/**
|
||||
* Retrieve cryopreserve matching the specified criteria.
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
* @return \Stemcell\Catalog\Api\Data\CryopreserveSearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete cryopreserve
|
||||
* @param \Stemcell\Catalog\Api\Data\CryopreserveInterface $cryopreserve
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function delete(
|
||||
\Stemcell\Catalog\Api\Data\CryopreserveInterface $cryopreserve
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete cryopreserve by ID
|
||||
* @param string $cryopreserveId
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function deleteById($cryopreserveId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface CellSortInterface
|
||||
{
|
||||
const CELLSORT_ID = 'cell_sort_id';
|
||||
const SPECIES_ID = 'species_id';
|
||||
const SPECIES_NAME = 'species_name';
|
||||
const CELL_TYPE_ID = 'cell_type_id';
|
||||
const CELL_TYPE_NAME = 'cell_type_name';
|
||||
|
||||
const CELL_SUBTYPE_ID = 'cell_subtype_id';
|
||||
const CELL_SUBTYPE_NAME = 'cell_subtype_name';
|
||||
|
||||
const TISSUE_ID = 'tissue_id';
|
||||
const TISSUE_NAME = 'tissue_name';
|
||||
const FLAG = 'flag';
|
||||
|
||||
const SKU = 'sku';
|
||||
|
||||
/**
|
||||
* Get cell_sort_id
|
||||
* @return int
|
||||
*/
|
||||
public function getCellSortId();
|
||||
|
||||
/**
|
||||
* Get species id
|
||||
* @return int
|
||||
*/
|
||||
public function getSpeciesId();
|
||||
|
||||
/**
|
||||
* Set species_name
|
||||
* @param int $speciesId
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setSpeciesId(int $speciesId);
|
||||
|
||||
/**
|
||||
* Get species_name
|
||||
* @return string
|
||||
*/
|
||||
public function getSpeciesName();
|
||||
|
||||
/**
|
||||
* Set species_name
|
||||
* @param string $speciesName
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setSpeciesName(string $speciesName);
|
||||
|
||||
/**
|
||||
* Get tissue_id
|
||||
* @return int
|
||||
*/
|
||||
public function getTissueId();
|
||||
|
||||
/**
|
||||
* Set tissue_id
|
||||
* @param int $tissueId
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setTissueId(int $tissueId);
|
||||
|
||||
/**
|
||||
* Get tissue_name
|
||||
* @return string
|
||||
*/
|
||||
public function getTissueName();
|
||||
|
||||
/**
|
||||
* Set tissue_name
|
||||
* @param string $tissueName
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setTissueName(string $tissueName);
|
||||
|
||||
/**
|
||||
* Get cell_type_id
|
||||
* @return int
|
||||
*/
|
||||
public function getCellTypeId();
|
||||
|
||||
/**
|
||||
* Set cell_type_id
|
||||
* @param int $cellTypeId
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setCellTypeId(int $cellTypeId);
|
||||
|
||||
/**
|
||||
* Get cell_type_name
|
||||
* @return string
|
||||
*/
|
||||
public function getCellTypeName();
|
||||
|
||||
/**
|
||||
* Set cell_type_name
|
||||
* @param string $cellTypeName
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setCellTypeName(string $cellTypeName);
|
||||
|
||||
/**
|
||||
* Get cell_subtype_id
|
||||
* @return int
|
||||
*/
|
||||
public function getCellSubTypeId();
|
||||
|
||||
/**
|
||||
* Set cell_subtype_id
|
||||
* @param int $cellSubTypeId
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setCellSubTypeId(int $cellSubTypeId);
|
||||
|
||||
/**
|
||||
* Get cell_subtype_name
|
||||
* @return string
|
||||
*/
|
||||
public function getCellSubTypeName();
|
||||
|
||||
/**
|
||||
* Set cell_subtype_name
|
||||
* @param string $cellSubTypeName
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setCellSubTypeName(string $cellSubTypeName);
|
||||
|
||||
/**
|
||||
* Get flag
|
||||
* @return string
|
||||
*/
|
||||
public function getFlag();
|
||||
|
||||
/**
|
||||
* Set flag
|
||||
* @param int $flag
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setFlag(int $flag);
|
||||
|
||||
/**
|
||||
* Get flag
|
||||
* @return string
|
||||
*/
|
||||
public function getSku();
|
||||
|
||||
/**
|
||||
* Set flag
|
||||
* @param string $sku
|
||||
* @return \Stemcell\Catalog\CellSort\Api\Data\CellSortInterface
|
||||
*/
|
||||
public function setSku(string $sku);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface CellSortSearchResultsInterface extends \Magento\Catalog\Api\Data\ProductSearchResultsInterface
|
||||
{
|
||||
const FILTERS = 'filters';
|
||||
|
||||
const LABELS = 'labels';
|
||||
/**
|
||||
* Get CellSort list.
|
||||
* @return string
|
||||
*/
|
||||
public function getFilters();
|
||||
|
||||
/**
|
||||
* Set cell_sort_id list.
|
||||
* @param string $filters
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilters(string $filters);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabels();
|
||||
|
||||
/**
|
||||
* Set cell_sort_id list.
|
||||
* @param string $filters
|
||||
* @return $this
|
||||
*/
|
||||
public function setLabels(string $labels);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface CellSubTypeInterface
|
||||
{
|
||||
|
||||
const NAME = 'name';
|
||||
const CELLSUBTYPE_ID = 'cell_subtype_id';
|
||||
|
||||
/**
|
||||
* Get cellsubtype_id
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCellsubtypeId();
|
||||
|
||||
/**
|
||||
* Set cellsubtype_id
|
||||
* @param string $cellsubtypeId
|
||||
* @return \Stemcell\Catalog\CellSubType\Api\Data\CellSubTypeInterface
|
||||
*/
|
||||
public function setCellsubtypeId($cellsubtypeId);
|
||||
|
||||
/**
|
||||
* Get name
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Set name
|
||||
* @param string $name
|
||||
* @return \Stemcell\Catalog\CellSubType\Api\Data\CellSubTypeInterface
|
||||
*/
|
||||
public function setName($name);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface CellSubTypeSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get CellSubType list.
|
||||
* @return \Stemcell\Catalog\Api\Data\CellSubTypeInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set name list.
|
||||
* @param \Stemcell\Catalog\Api\Data\CellSubTypeInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface CellTypeInterface
|
||||
{
|
||||
|
||||
const CELL_TYPE_NAME = 'cell_type_name';
|
||||
const CELL_TYPE_ID = 'cell_type_id';
|
||||
|
||||
/**
|
||||
* Get celltype_id
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCelltypeId();
|
||||
|
||||
/**
|
||||
* Get cell_type_name
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCellTypeName();
|
||||
|
||||
/**
|
||||
* Set cell_type_name
|
||||
* @param string $cellTypeName
|
||||
* @return \Stemcell\Catalog\CellType\Api\Data\CellTypeInterface
|
||||
*/
|
||||
public function setCellTypeName($cellTypeName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface CellTypeSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get CellType list.
|
||||
* @return \Stemcell\Catalog\Api\Data\CellTypeInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set cell_type_name list.
|
||||
* @param \Stemcell\Catalog\Api\Data\CellTypeInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface CryopreserveInterface
|
||||
{
|
||||
|
||||
const TYPE = 'type';
|
||||
const DESC = 'desc';
|
||||
const CRYOPRESERVE_ID = 'cryopreserve_id';
|
||||
const REFERENCE_DENSITY = 'reference_density';
|
||||
const REFERENCE = 'reference';
|
||||
const SAMPLE = 'sample';
|
||||
const CELL_TYPE = 'cell_type';
|
||||
|
||||
/**
|
||||
* Get cryopreserve_id
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCryopreserveId();
|
||||
|
||||
/**
|
||||
* Get sample
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSample();
|
||||
|
||||
/**
|
||||
* Set sample
|
||||
* @param string $sample
|
||||
* @return \Stemcell\Catalog\Cryopreserve\Api\Data\CryopreserveInterface
|
||||
*/
|
||||
public function setSample(string $sample);
|
||||
|
||||
/**
|
||||
* Get type
|
||||
* @return string|null
|
||||
*/
|
||||
public function getType();
|
||||
|
||||
/**
|
||||
* Set type
|
||||
* @param string $type
|
||||
* @return \Stemcell\Catalog\Cryopreserve\Api\Data\CryopreserveInterface
|
||||
*/
|
||||
public function setType(string $type);
|
||||
|
||||
/**
|
||||
* Get cell_type
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCellType();
|
||||
|
||||
/**
|
||||
* Set cell_type
|
||||
* @param string $cellType
|
||||
* @return \Stemcell\Catalog\Cryopreserve\Api\Data\CryopreserveInterface
|
||||
*/
|
||||
public function setCellType(string $cellType);
|
||||
|
||||
/**
|
||||
* Get reference_density
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReferenceDensity();
|
||||
|
||||
/**
|
||||
* Set reference_density
|
||||
* @param string $referenceDensity
|
||||
* @return \Stemcell\Catalog\Cryopreserve\Api\Data\CryopreserveInterface
|
||||
*/
|
||||
public function setReferenceDensity(string $referenceDensity);
|
||||
|
||||
/**
|
||||
* Get desc
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDesc();
|
||||
|
||||
/**
|
||||
* Set desc
|
||||
* @param string $desc
|
||||
* @return \Stemcell\Catalog\Cryopreserve\Api\Data\CryopreserveInterface
|
||||
*/
|
||||
public function setDesc(string $desc);
|
||||
|
||||
/**
|
||||
* Get reference
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReference();
|
||||
|
||||
/**
|
||||
* Set reference
|
||||
* @param string $reference
|
||||
* @return \Stemcell\Catalog\Cryopreserve\Api\Data\CryopreserveInterface
|
||||
*/
|
||||
public function setReference(string $reference);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface CryopreserveSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get cryopreserve list.
|
||||
* @return \Stemcell\Catalog\Api\Data\CryopreserveInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set id list.
|
||||
* @param \Stemcell\Catalog\Api\Data\CryopreserveInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface ExperimentalSchemeInterface
|
||||
{
|
||||
|
||||
const EXPERIMENTALSCHEME_ID = 'experimental_scheme_id';
|
||||
const MP_URL = 'mp_url';
|
||||
const IMAGE = 'image';
|
||||
const TITLE = 'title';
|
||||
|
||||
const COLLECTION_SORT = 'collection_sort';
|
||||
const COLLECTION_NAME = 'collection_name';
|
||||
|
||||
/**
|
||||
* Get experimental_scheme_id
|
||||
* @return string|null
|
||||
*/
|
||||
public function getExperimentalschemeId();
|
||||
|
||||
/**
|
||||
* Get collection_name
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCollectionName();
|
||||
|
||||
/**
|
||||
* Set collection_name
|
||||
* @param string $collectionName
|
||||
* @return \Stemcell\Catalog\ExperimentalScheme\Api\Data\ExperimentalSchemeInterface
|
||||
*/
|
||||
public function setCollectionName(string $collectionName);
|
||||
|
||||
/**
|
||||
* Get collection_sort
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCollectionSort();
|
||||
|
||||
/**
|
||||
* Set collection_sort
|
||||
* @param int $collectionSort
|
||||
* @return \Stemcell\Catalog\ExperimentalScheme\Api\Data\ExperimentalSchemeInterface
|
||||
*/
|
||||
public function setCollectionSort(int $collectionSort);
|
||||
|
||||
/**
|
||||
* Get title
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitle();
|
||||
|
||||
/**
|
||||
* Set title
|
||||
* @param string $title
|
||||
* @return \Stemcell\Catalog\ExperimentalScheme\Api\Data\ExperimentalSchemeInterface
|
||||
*/
|
||||
public function setTitle(string $title);
|
||||
|
||||
/**
|
||||
* Get image
|
||||
* @return string|null
|
||||
*/
|
||||
public function getImage();
|
||||
|
||||
/**
|
||||
* Set image
|
||||
* @param string $image
|
||||
* @return \Stemcell\Catalog\ExperimentalScheme\Api\Data\ExperimentalSchemeInterface
|
||||
*/
|
||||
public function setImage(string $image);
|
||||
|
||||
/**
|
||||
* Get mp_url
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMpUrl();
|
||||
|
||||
/**
|
||||
* Set mp_url
|
||||
* @param string $mpUrl
|
||||
* @return \Stemcell\Catalog\ExperimentalScheme\Api\Data\ExperimentalSchemeInterface
|
||||
*/
|
||||
public function setMpUrl(string $mpUrl);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface ExperimentalSchemeSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get ExperimentalScheme list.
|
||||
* @return \Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set collection_name list.
|
||||
* @param \Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface ProductListWithFilterInterface extends \Magento\Catalog\Api\Data\ProductSearchResultsInterface
|
||||
{
|
||||
/**
|
||||
* @param string $filter
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilters(string $filter);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilters();
|
||||
|
||||
/**
|
||||
* @param string $filterCode
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilterCode(string $filterCode);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilterCode();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface ProductManualSearchInterface
|
||||
{
|
||||
|
||||
const NAME = 'name';
|
||||
const SKU = 'sku';
|
||||
const SEARCH_ID = 'search_id';
|
||||
const SEARCH_SKU = 'search_sku';
|
||||
|
||||
/**
|
||||
* Get search_id
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSearchId();
|
||||
|
||||
/**
|
||||
* Get name
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Set name
|
||||
* @param string $name
|
||||
* @return \Stemcell\Catalog\Api\Data\ProductManualSearchInterface
|
||||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* Get sku
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSku();
|
||||
|
||||
/**
|
||||
* Set sku
|
||||
* @param string $sku
|
||||
* @return \Stemcell\Catalog\Api\Data\ProductManualSearchInterface
|
||||
*/
|
||||
public function setSku($sku);
|
||||
|
||||
/**
|
||||
* Get search_sku
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSearchSku();
|
||||
|
||||
/**
|
||||
* Set search_sku
|
||||
* @param string $searchSku
|
||||
* @return \Stemcell\Catalog\Api\Data\ProductManualSearchInterface
|
||||
*/
|
||||
public function setSearchSku($searchSku);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface ProductManualSearchSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get ProductManualSearch list.
|
||||
* @return \Stemcell\Catalog\Api\Data\ProductManualSearchInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set name list.
|
||||
* @param \Stemcell\Catalog\Api\Data\ProductManualSearchInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface SpeciesInterface
|
||||
{
|
||||
|
||||
const SPECIES_NAME = 'species_name';
|
||||
const SPECIES_ID = 'species_id';
|
||||
|
||||
/**
|
||||
* Get species_name
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSpeciesName();
|
||||
|
||||
/**
|
||||
* Set species_name
|
||||
* @param string $speciesName
|
||||
* @return \Stemcell\Catalog\Species\Api\Data\SpeciesInterface
|
||||
*/
|
||||
public function setSpeciesName($speciesName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface SpeciesSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get Species list.
|
||||
* @return \Stemcell\Catalog\Api\Data\SpeciesInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set species_id list.
|
||||
* @param \Stemcell\Catalog\Api\Data\SpeciesInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface TissueInterface
|
||||
{
|
||||
|
||||
const TISSUE_ID = 'tissue_id';
|
||||
const TISSUE_NAME = 'tissue_name';
|
||||
|
||||
/**
|
||||
* Get tissue_id
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTissueId();
|
||||
|
||||
/**
|
||||
* Get tissue_name
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTissueName();
|
||||
|
||||
/**
|
||||
* Set tissue_name
|
||||
* @param string $tissueName
|
||||
* @return \Stemcell\Catalog\Tissue\Api\Data\TissueInterface
|
||||
*/
|
||||
public function setTissueName($tissueName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api\Data;
|
||||
|
||||
interface TissueSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get Tissue list.
|
||||
* @return \Stemcell\Catalog\Api\Data\TissueInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* Set tissue_id list.
|
||||
* @param \Stemcell\Catalog\Api\Data\TissueInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(array $items);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface ExperimentalSchemeRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Save ExperimentalScheme
|
||||
* @param \Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface $experimentalScheme
|
||||
* @return \Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function save(
|
||||
\Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface $experimentalScheme
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve ExperimentalScheme
|
||||
* @param string $experimentalschemeId
|
||||
* @return \Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function get($experimentalschemeId);
|
||||
|
||||
/**
|
||||
* Retrieve ExperimentalScheme matching the specified criteria.
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
* @return \Stemcell\Catalog\Api\Data\ExperimentalSchemeSearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete ExperimentalScheme
|
||||
* @param \Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface $experimentalScheme
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function delete(
|
||||
\Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface $experimentalScheme
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete ExperimentalScheme by ID
|
||||
* @param string $experimentalschemeId
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function deleteById($experimentalschemeId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface ProductManualSearchRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Save ProductManualSearch
|
||||
* @param \Stemcell\Catalog\Api\Data\ProductManualSearchInterface $productManualSearch
|
||||
* @return \Stemcell\Catalog\Api\Data\ProductManualSearchInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function save(
|
||||
\Stemcell\Catalog\Api\Data\ProductManualSearchInterface $productManualSearch
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve ProductManualSearch
|
||||
* @param string $productmanualsearchId
|
||||
* @return \Stemcell\Catalog\Api\Data\ProductManualSearchInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function get($productmanualsearchId);
|
||||
|
||||
/**
|
||||
* Retrieve ProductManualSearch matching the specified criteria.
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
* @return \Stemcell\Catalog\Api\Data\ProductManualSearchSearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete ProductManualSearch
|
||||
* @param \Stemcell\Catalog\Api\Data\ProductManualSearchInterface $productManualSearch
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function delete(
|
||||
\Stemcell\Catalog\Api\Data\ProductManualSearchInterface $productManualSearch
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete ProductManualSearch by ID
|
||||
* @param string $productmanualsearchId
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function deleteById($productmanualsearchId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface SpeciesRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Save Species
|
||||
* @param \Stemcell\Catalog\Api\Data\SpeciesInterface $species
|
||||
* @return \Stemcell\Catalog\Api\Data\SpeciesInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function save(
|
||||
\Stemcell\Catalog\Api\Data\SpeciesInterface $species
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve Species
|
||||
* @param string $speciesId
|
||||
* @return \Stemcell\Catalog\Api\Data\SpeciesInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function get($speciesId);
|
||||
|
||||
/**
|
||||
* Retrieve Species matching the specified criteria.
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
* @return \Stemcell\Catalog\Api\Data\SpeciesSearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete Species
|
||||
* @param \Stemcell\Catalog\Api\Data\SpeciesInterface $species
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function delete(
|
||||
\Stemcell\Catalog\Api\Data\SpeciesInterface $species
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete Species by ID
|
||||
* @param string $speciesId
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function deleteById($speciesId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Api;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteriaInterface;
|
||||
|
||||
interface TissueRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Save Tissue
|
||||
* @param \Stemcell\Catalog\Api\Data\TissueInterface $tissue
|
||||
* @return \Stemcell\Catalog\Api\Data\TissueInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function save(
|
||||
\Stemcell\Catalog\Api\Data\TissueInterface $tissue
|
||||
);
|
||||
|
||||
/**
|
||||
* Retrieve Tissue
|
||||
* @param string $tissueId
|
||||
* @return \Stemcell\Catalog\Api\Data\TissueInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function get($tissueId);
|
||||
|
||||
/**
|
||||
* Retrieve Tissue matching the specified criteria.
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
* @return \Stemcell\Catalog\Api\Data\TissueSearchResultsInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete Tissue
|
||||
* @param \Stemcell\Catalog\Api\Data\TissueInterface $tissue
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function delete(
|
||||
\Stemcell\Catalog\Api\Data\TissueInterface $tissue
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete Tissue by ID
|
||||
* @param string $tissueId
|
||||
* @return bool true on success
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function deleteById($tissueId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Adminhtml\Price\Import;
|
||||
|
||||
use Magento\Customer\Block\Adminhtml\Edit\GenericButton;
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class BackButton 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_catalog/price/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Adminhtml\Price\Import;
|
||||
|
||||
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_catalog/price/sample');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Adminhtml\Stock;
|
||||
|
||||
use Magento\Customer\Block\Adminhtml\Edit\GenericButton;
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class BackButton 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_catalog/stock/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Adminhtml\Stock;
|
||||
|
||||
class Import extends \Magento\Backend\Block\Template
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Adminhtml\Stock;
|
||||
|
||||
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_catalog/stock/sample');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Adminhtml\Stock;
|
||||
|
||||
use Magento\Customer\Block\Adminhtml\Edit\GenericButton;
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class SaveButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('导入'),
|
||||
'class' => 'save primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => ['button' => ['event' => 'save']],
|
||||
'form-role' => 'save',
|
||||
],
|
||||
'sort_order' => 90,
|
||||
];
|
||||
}
|
||||
|
||||
public function getUrl($route = '', $params = [])
|
||||
{
|
||||
return $this->urlBuilder->getUrl('stemcell_catalog/stock/importPost');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Pricing\Render;
|
||||
|
||||
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;
|
||||
use Magento\Catalog\Pricing\Price\MinimalPriceCalculatorInterface;
|
||||
use Magento\Framework\Pricing\Price\PriceInterface;
|
||||
use Magento\Framework\Pricing\Render\RendererPool;
|
||||
use Magento\Framework\Pricing\SaleableInterface;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Stemcell\Catalog\Helper\Product\View;
|
||||
|
||||
class FinalPriceBox extends \Magento\Catalog\Pricing\Render\FinalPriceBox
|
||||
{
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
SaleableInterface $saleableItem,
|
||||
PriceInterface $price,
|
||||
RendererPool $rendererPool,
|
||||
protected View $productViewHelper,
|
||||
array $data = [],
|
||||
SalableResolverInterface $salableResolver = null,
|
||||
MinimalPriceCalculatorInterface $minimalPriceCalculator = null
|
||||
) {
|
||||
parent::__construct(
|
||||
$context,
|
||||
$saleableItem,
|
||||
$price,
|
||||
$rendererPool,
|
||||
$data,
|
||||
$salableResolver,
|
||||
$minimalPriceCalculator
|
||||
);
|
||||
}
|
||||
|
||||
protected function _toHtml()
|
||||
{
|
||||
if ($this->productViewHelper->notStockCheckGroup()) {
|
||||
return parent::_toHtml();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Product;
|
||||
|
||||
use Magento\Catalog\Api\Data\ProductInterface;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product\Type;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Stemcell\SubItemProduct\Model\ResourceModel\SubItem\CollectionFactory;
|
||||
use Stemcell\SubItemProduct\Model\SubItem as SubItemModel;
|
||||
use Stemcell\Catalog\Helper\Product\View as ProductViewHelper;
|
||||
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableProductType;
|
||||
|
||||
class View extends \Magento\Catalog\Block\Product\View
|
||||
{
|
||||
const NOT_FOR_SELL_SKU_PATH = 'catalog/product_settings/not_for_sell';
|
||||
const NO_PRICE_SKU_PATH = 'catalog/product_settings/no_price_sku';
|
||||
const WENJUANXING_ENQUIRY_URL = 'stemcell_web/wenjuanxing/enquiry_url';
|
||||
|
||||
const STOCK_CHECK_GROUP_PATH = 'stemcell_web/catalog/stock_check_group';
|
||||
|
||||
public function __construct(
|
||||
\Magento\Catalog\Block\Product\Context $context,
|
||||
\Magento\Framework\Url\EncoderInterface $urlEncoder,
|
||||
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
|
||||
\Magento\Framework\Stdlib\StringUtils $string,
|
||||
\Magento\Catalog\Helper\Product $productHelper,
|
||||
\Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig,
|
||||
\Magento\Framework\Locale\FormatInterface $localeFormat,
|
||||
\Magento\Customer\Model\Session $customerSession,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
|
||||
private ScopeConfigInterface $scopeConfig,
|
||||
protected ProductViewHelper $productViewHelper,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct(
|
||||
$context, $urlEncoder, $jsonEncoder, $string, $productHelper, $productTypeConfig,
|
||||
$localeFormat, $customerSession, $productRepository, $priceCurrency, $data
|
||||
);
|
||||
}
|
||||
|
||||
public function showEnquiry(ProductInterface $product)
|
||||
{
|
||||
$notSellSkus = [];
|
||||
if ($product->getTypeId() == Type::TYPE_SIMPLE && $product->getPrice()==0) {
|
||||
$notSellSkus[] = $product->getSku();
|
||||
}
|
||||
|
||||
if ($product->getTypeId() == ConfigurableProductType::TYPE_CODE) {
|
||||
$childProducts = $product->getTypeInstance()->getUsedProducts($product);
|
||||
|
||||
foreach ($childProducts as $child) {
|
||||
if ($child->getPrice() == 0) {
|
||||
$notSellSkus[] = $child->getSku();
|
||||
}
|
||||
}
|
||||
}
|
||||
return !empty($notSellSkus);
|
||||
}
|
||||
|
||||
public function isConfigurable(ProductInterface $product)
|
||||
{
|
||||
return $product->getTypeId() == ConfigurableProductType::TYPE_CODE;
|
||||
}
|
||||
/**
|
||||
* 根据大货号(简单产品或可配置产品的子产品)的的库存计算出产品的库存量
|
||||
* @return int
|
||||
*/
|
||||
public function getStockFromSubItems(ProductInterface $product){
|
||||
|
||||
return $this->productViewHelper->getStockFromSubItems($product);
|
||||
}
|
||||
|
||||
public function getWenjuanxingEnquiryUrl(){
|
||||
$url = (string)$this->scopeConfig->getValue(self::WENJUANXING_ENQUIRY_URL);
|
||||
return trim($url);
|
||||
}
|
||||
|
||||
public function notStockCheckGroup()
|
||||
{
|
||||
return $this->productViewHelper->notStockCheckGroup();
|
||||
}
|
||||
|
||||
public function isLoggedIn()
|
||||
{
|
||||
return $this->customerSession->isLoggedIn();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Product\View;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Helper\Image as ImageHelper;
|
||||
use Magento\Catalog\Model\ProductFactory;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\Collection;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
|
||||
|
||||
class Publication extends \Magento\Catalog\Block\Product\View
|
||||
{
|
||||
private const VISIBLE_PUBLICATION_LIMIT = 3;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Catalog\Block\Product\Context $context,
|
||||
\Magento\Framework\Url\EncoderInterface $urlEncoder,
|
||||
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
|
||||
\Magento\Framework\Stdlib\StringUtils $string,
|
||||
\Magento\Catalog\Helper\Product $productHelper,
|
||||
\Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig,
|
||||
\Magento\Framework\Locale\FormatInterface $localeFormat,
|
||||
\Magento\Customer\Model\Session $customerSession,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
|
||||
protected ProductCollectionFactory $productCollectionFactory,
|
||||
protected \Magento\Framework\Registry $registry,
|
||||
protected ProductFactory $productFactory,
|
||||
protected ImageHelper $imageHelper,
|
||||
array $data = []
|
||||
)
|
||||
{
|
||||
parent::__construct(
|
||||
$context,
|
||||
$urlEncoder,
|
||||
$jsonEncoder,
|
||||
$string,
|
||||
$productHelper,
|
||||
$productTypeConfig,
|
||||
$localeFormat,
|
||||
$customerSession,
|
||||
$productRepository,
|
||||
$priceCurrency,
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
public function getProducts(): Collection
|
||||
{
|
||||
return $this->getPublicationCollection()
|
||||
->setPageSize(self::VISIBLE_PUBLICATION_LIMIT)
|
||||
->setCurPage(1);
|
||||
}
|
||||
|
||||
public function getProductsCount(): int
|
||||
{
|
||||
return $this->getPublicationCollection()->getSize();
|
||||
}
|
||||
|
||||
private function getPublicationCollection(): Collection
|
||||
{
|
||||
$product = $this->getProduct();
|
||||
|
||||
$publicationSkus = trim((string)$product->getData('publication_skus'));
|
||||
$collection = $this->productCollectionFactory->create()
|
||||
->addAttributeToSelect([
|
||||
'name',
|
||||
'sku',
|
||||
'reference_url',
|
||||
'reference_abstract',
|
||||
'author_info',
|
||||
'reference_journal',
|
||||
'resource_type',
|
||||
'reference_year',
|
||||
'reference_month',
|
||||
])
|
||||
->addStoreFilter();
|
||||
|
||||
if (!$publicationSkus) {
|
||||
return $this->getEmptyCollection($collection);
|
||||
}
|
||||
|
||||
$skus = array_values(array_filter(array_map('trim', explode(',', $publicationSkus))));
|
||||
if (!$skus) {
|
||||
return $this->getEmptyCollection($collection);
|
||||
}
|
||||
|
||||
return $collection->addAttributeToFilter('sku', ['in' => $skus]);
|
||||
}
|
||||
|
||||
protected function getEmptyCollection(Collection $collection): Collection
|
||||
{
|
||||
$collection->addAttributeToFilter('entity_id', ['null' => true]);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function getOptionIdByLabel(
|
||||
\Magento\Catalog\Model\Product $product,
|
||||
string $attributeCode,
|
||||
string $label
|
||||
): ?int {
|
||||
$attribute = $product->getResource()->getAttribute($attributeCode);
|
||||
|
||||
if (!$attribute || !$attribute->usesSource()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$optionId = $attribute->getSource()->getOptionId($label);
|
||||
|
||||
return $optionId ? (int)$optionId : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPublicationListUrl()
|
||||
{
|
||||
$categoryOptionId = $this->getOptionIdByLabel($this->getProduct(), 'category_option', '文档');
|
||||
$resourceTypeId = $this->getOptionIdByLabel($this->getProduct(), 'resource_type', '文献');
|
||||
|
||||
return $this->getUrl(
|
||||
'catalogsearch/result/index',
|
||||
[
|
||||
'_query' => [
|
||||
'category_option' => $categoryOptionId,
|
||||
'resource_type' => $resourceTypeId,
|
||||
'q' => str_ireplace('_C', '', $this->getProduct()->getSku())
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Product\View;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Helper\Image as ImageHelper;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\Collection;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
|
||||
use Magento\Catalog\Model\ProductFactory;
|
||||
|
||||
class TechnicalResource extends \Magento\Catalog\Block\Product\View
|
||||
{
|
||||
public function __construct(
|
||||
\Magento\Catalog\Block\Product\Context $context,
|
||||
\Magento\Framework\Url\EncoderInterface $urlEncoder,
|
||||
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
|
||||
\Magento\Framework\Stdlib\StringUtils $string,
|
||||
\Magento\Catalog\Helper\Product $productHelper,
|
||||
\Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig,
|
||||
\Magento\Framework\Locale\FormatInterface $localeFormat,
|
||||
\Magento\Customer\Model\Session $customerSession,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
|
||||
protected ProductCollectionFactory $productCollectionFactory,
|
||||
protected \Magento\Framework\Registry $registry,
|
||||
protected ProductFactory $productFactory,
|
||||
protected ImageHelper $imageHelper,
|
||||
array $data = []
|
||||
)
|
||||
{
|
||||
parent::__construct(
|
||||
$context,
|
||||
$urlEncoder,
|
||||
$jsonEncoder,
|
||||
$string,
|
||||
$productHelper,
|
||||
$productTypeConfig,
|
||||
$localeFormat,
|
||||
$customerSession,
|
||||
$productRepository,
|
||||
$priceCurrency,
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
public function getCurrentProduct()
|
||||
{
|
||||
$product = $this->registry->registry('product');
|
||||
if (!$product) {
|
||||
$product = $this->productFactory->create();
|
||||
}
|
||||
return $product;
|
||||
}
|
||||
|
||||
protected function getEmptyCollection(Collection $collection): Collection
|
||||
{
|
||||
$collection->addAttributeToFilter('entity_id', ['null' => true]);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function getProducts(): Collection
|
||||
{
|
||||
$product = $this->getProduct();
|
||||
|
||||
$technicalResourceSkus = $product->getData('technical_resource_skus');
|
||||
$collection = $this->productCollectionFactory->create()
|
||||
->addAttributeToSelect([
|
||||
'name',
|
||||
'sku',
|
||||
'url_key',
|
||||
'image',
|
||||
'small_image',
|
||||
'thumbnail',
|
||||
'resource_type',
|
||||
'form_link',
|
||||
'document_path',
|
||||
])
|
||||
->addStoreFilter();
|
||||
|
||||
if (!$technicalResourceSkus) {
|
||||
return $this->getEmptyCollection($collection);
|
||||
}
|
||||
|
||||
$skus = array_values(array_filter(array_map('trim', explode(',', $technicalResourceSkus))));
|
||||
if (!$skus) {
|
||||
return $collection->addIdFilter([]);
|
||||
}
|
||||
|
||||
return $collection->addAttributeToFilter('sku', ['in' => $skus]);
|
||||
}
|
||||
|
||||
public function getTechnicalResourceProductUrl(Product $product)
|
||||
{
|
||||
$resourceType = (string)$product->getAttributeText('resource_type');
|
||||
$resourceType = trim($resourceType);
|
||||
if (in_array($resourceType, ['挂图','点播课程'])) {
|
||||
return $product->getData('form_link');
|
||||
} elseif ($product->getData('document_path')) {
|
||||
return $product->getData('document_path');
|
||||
}
|
||||
|
||||
return $this->getProductUrl($product);
|
||||
}
|
||||
|
||||
public function getProductImageUrl(Product $product, int $width = 303, int $height = 170): string
|
||||
{
|
||||
return $this->imageHelper
|
||||
->init($product, 'product_base_image')
|
||||
->resize($width, $height)
|
||||
->getUrl();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Block\Theme\Html;
|
||||
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Data\Tree\Node;
|
||||
use Magento\Framework\Data\Tree\Node\Collection;
|
||||
use Magento\Framework\Data\Tree\NodeFactory;
|
||||
use Magento\Framework\Data\TreeFactory;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Topmenu extends \Magento\Theme\Block\Html\Topmenu
|
||||
{
|
||||
/**
|
||||
* @var NodeFactory
|
||||
*/
|
||||
protected $nodeFactory;
|
||||
|
||||
/**
|
||||
* @var TreeFactory
|
||||
*/
|
||||
protected $treeFactory;
|
||||
|
||||
protected function getChildLevel($parentLevel): int
|
||||
{
|
||||
return $parentLevel === null ? 0 : $parentLevel + 1;
|
||||
}
|
||||
|
||||
protected function removeChildrenWithoutActiveParent(Collection $children, int $childLevel): void
|
||||
{
|
||||
/** @var Node $child */
|
||||
foreach ($children as $child) {
|
||||
if ($childLevel === 0 && $child->getData('is_parent_active') === false) {
|
||||
$children->delete($child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function setCurrentClass(Node $child, string $outermostClass): void
|
||||
{
|
||||
$currentClass = $child->getClass();
|
||||
if (empty($currentClass)) {
|
||||
$child->setClass($outermostClass);
|
||||
} else {
|
||||
$child->setClass($currentClass . ' ' . $outermostClass);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*
|
||||
* @param array $colBrakes
|
||||
* @param int $counter
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldAddNewColumn(array $colBrakes, int $counter): bool
|
||||
{
|
||||
return count($colBrakes) && $colBrakes[$counter]['colbrake'];
|
||||
}
|
||||
|
||||
protected function getCategoryUrl(Node $node)
|
||||
{
|
||||
// $logger = ObjectManager::getInstance()->get(LoggerInterface::class);
|
||||
// $logger->info('stemcell $node', ['$node->getData()'=>$node->getData()]);
|
||||
if ($node->getUrl()) {
|
||||
$path = parse_url($node->getUrl(), PHP_URL_PATH);
|
||||
if (ltrim($path, '/') === 'products.html') {
|
||||
return '/products/product-types.html';
|
||||
}
|
||||
}
|
||||
|
||||
return $node->getUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*
|
||||
* @param Node $menuTree
|
||||
* @param string $childrenWrapClass
|
||||
* @param int $limit
|
||||
* @param array $colBrakes
|
||||
* @return string
|
||||
*/
|
||||
protected function _getHtml(
|
||||
Node $menuTree,
|
||||
$childrenWrapClass,
|
||||
$limit,
|
||||
array $colBrakes = []
|
||||
) {
|
||||
$html = '';
|
||||
|
||||
$children = $menuTree->getChildren();
|
||||
$childLevel = $this->getChildLevel($menuTree->getLevel());
|
||||
$this->removeChildrenWithoutActiveParent($children, $childLevel);
|
||||
|
||||
$counter = 1;
|
||||
$childrenCount = $children->count();
|
||||
|
||||
$parentPositionClass = $menuTree->getPositionClass();
|
||||
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
|
||||
|
||||
/** @var Node $child */
|
||||
foreach ($children as $child) {
|
||||
$child->setLevel($childLevel);
|
||||
$child->setIsFirst($counter === 1);
|
||||
$child->setIsLast($counter === $childrenCount);
|
||||
$child->setPositionClass($itemPositionClassPrefix . $counter);
|
||||
|
||||
$outermostClassCode = '';
|
||||
$outermostClass = $menuTree->getOutermostClass();
|
||||
|
||||
if ($childLevel === 0 && $outermostClass) {
|
||||
$outermostClassCode = ' class="' . $outermostClass . '" ';
|
||||
$this->setCurrentClass($child, $outermostClass);
|
||||
}
|
||||
|
||||
if ($this->shouldAddNewColumn($colBrakes, $counter)) {
|
||||
$html .= '</ul></li><li class="column"><ul>';
|
||||
}
|
||||
|
||||
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
|
||||
$html .= '<a href="' . $this->getCategoryUrl($child) . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml(
|
||||
$child->getName()
|
||||
) . '</span></a>' . $this->_addSubMenu(
|
||||
$child,
|
||||
$childLevel,
|
||||
$childrenWrapClass,
|
||||
$limit
|
||||
) . '</li>';
|
||||
$counter++;
|
||||
}
|
||||
|
||||
if (is_array($colBrakes) && !empty($colBrakes) && $limit) {
|
||||
$html = '<li class="column"><ul>' . $html . '</ul></li>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
Copyright © 2025-present
|
||||
|
||||
This file is part of Stemcell/Catalog.
|
||||
|
||||
Stemcell/Catalog is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
Please see LICENSE.txt for the full text of GNU General Public License
|
||||
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product\Visibility;
|
||||
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellType as CellTypeResource;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellSubType as CellSubTypeResource;
|
||||
use Stemcell\Catalog\Model\ResourceModel\Species as SpeciesResource;
|
||||
use Stemcell\Catalog\Model\ResourceModel\Tissue as TissueResource;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellSort as CellSortResource;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Magento\Framework\Filesystem\Driver\File;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use Magento\Eav\Model\ResourceModel\ReadHandler;
|
||||
|
||||
/**
|
||||
* 细胞分选工具数据导入
|
||||
* 调用此接口前,请先运行一次cell:sort:import命令,导入数据
|
||||
*/
|
||||
class CellSortImport extends Command
|
||||
{
|
||||
protected $parentProduct = [];
|
||||
|
||||
protected OutputInterface $output;
|
||||
|
||||
public function __construct(
|
||||
private Dir $dir,
|
||||
private File $file,
|
||||
private Json $json,
|
||||
private SpeciesResource $speciesResource,
|
||||
private CellTypeResource $cellTypeResource,
|
||||
private CellSubTypeResource $cellSubTypeResource,
|
||||
private TissueResource $tissueResource,
|
||||
private CellSortResource $cellSortResource,
|
||||
private Configurable $configurableProduct,
|
||||
private ProductRepositoryInterface $productRepository,
|
||||
){
|
||||
parent::__construct('cell:sort:import');
|
||||
$this->setDescription('细胞分选工具数据导入');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws \Magento\Framework\Exception\FileSystemException
|
||||
*/
|
||||
protected function getPcas() {
|
||||
$pcas = $this->dir->getDir('Stemcell_Catalog').'/data/pcas-code.json';
|
||||
foreach ($this->json->unserialize($this->file->fileGetContents($pcas)) as $item) {
|
||||
$this->provinces[$item['name']] = str_pad($item['code'], 6, '0');
|
||||
}
|
||||
}
|
||||
|
||||
protected function getSpreadsheet()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/cell-select-tool.xlsx';
|
||||
if (!file_exists($path)) {
|
||||
throw new \Exception(sprintf('File %s does not exist', $path));
|
||||
}
|
||||
|
||||
return IOFactory::load($path);
|
||||
}
|
||||
|
||||
protected function getParentProduct(string $childSku)
|
||||
{
|
||||
try {
|
||||
if (!isset($this->parentProduct[$childSku])) {
|
||||
$product = $this->productRepository->get($childSku);
|
||||
if ($product->getVisibility()== Visibility::VISIBILITY_NOT_VISIBLE) {
|
||||
$parentIds = $this->configurableProduct->getParentIdsByChild($product->getId());
|
||||
if (!empty($parentIds)) {
|
||||
$configurableProduct = $this->productRepository->getById(reset($parentIds));
|
||||
$this->parentProduct[$childSku] = $configurableProduct->getSku();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->parentProduct[$childSku];
|
||||
} catch (\Exception $exception) {
|
||||
$this->output->writeln('<error>' . sprintf('get parent product from %s fail', $childSku) . '</error>, because: ' . $exception->getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除旧数据
|
||||
* @return void
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
protected function previousDataClean()
|
||||
{
|
||||
$this->speciesResource->getConnection()->query('TRUNCATE TABLE '.$this->speciesResource->getMainTable());
|
||||
$this->cellTypeResource->getConnection()->query('TRUNCATE TABLE '.$this->cellTypeResource->getMainTable());
|
||||
$this->cellSubTypeResource->getConnection()->query('TRUNCATE TABLE '.$this->cellSubTypeResource->getMainTable());
|
||||
$this->tissueResource->getConnection()->query('TRUNCATE TABLE '.$this->tissueResource->getMainTable());
|
||||
$this->cellSortResource->getConnection()->query('TRUNCATE TABLE '.$this->cellSortResource->getMainTable());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function getSpecies(array $data)
|
||||
{
|
||||
$species = [];
|
||||
foreach ($data as $item) {
|
||||
$species[$item['species']] = ['species_name' => $item['species'], 'species_sort' => $item['specieSort']];
|
||||
}
|
||||
return array_values($species);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function getCellType(array $data)
|
||||
{
|
||||
$cellTypes = [];
|
||||
foreach ($data as $item) {
|
||||
$cellTypes[$item['cellType']] = ['cell_type_name' => $item['cellType'], 'cell_type_sort' => $item['cellTypeSort']];
|
||||
}
|
||||
return array_values($cellTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
* @return int
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->previousDataClean();
|
||||
|
||||
$spreadsheet = $this->getSpreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$lastRow = $sheet->getHighestRow();
|
||||
$temp = $data = [];
|
||||
for ($row = 2; $row <= $lastRow; ++$row) {
|
||||
$skus = $sheet->getCell('J' . $row)->getValue();
|
||||
if ($skus) {
|
||||
$species = $sheet->getCell('B' . $row)->getValue();
|
||||
$specieSort = intval(trim((string)$sheet->getCell('C' . $row)->getValue()));
|
||||
$cellType = $sheet->getCell('D' . $row)->getValue();
|
||||
$cellTypeSort = intval(trim((string)$sheet->getCell('E' . $row)->getValue()));
|
||||
$cellSubType = $sheet->getCell('F' . $row)->getValue();
|
||||
$cellSubTypeSort = $sheet->getCell('K' . $row)->getValue();
|
||||
$tissue = explode("\n", (string)$sheet->getCell('G' . $row)->getValue());
|
||||
$positive = $sheet->getCell('H' . $row)->getValue();
|
||||
$negative = $sheet->getCell('I' . $row)->getValue();
|
||||
$skus = explode("\n", $skus);
|
||||
|
||||
$temp[$row] = [
|
||||
'species'=>trim($species), 'specieSort'=>$specieSort, 'cellType'=>trim($cellType), 'cellTypeSort'=>$cellTypeSort,
|
||||
'cellSubType'=>trim($cellSubType), 'cellSubTypeSort'=>$cellSubTypeSort, 'tissue'=>$tissue, 'positive'=>$positive, 'negative'=>$negative, 'sku'=>$skus
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$cellSubTypeData = [];
|
||||
$maxCellSubTypeSort = 0;
|
||||
foreach ($temp as $item) {
|
||||
if (!isset($cellSubTypeData[$item['cellSubType']])) {
|
||||
$cellSubTypeData[$item['cellSubType']] = ['cellSubType'=>$item['cellSubType'], 'cellSubTypeSort'=>$item['cellSubTypeSort']];
|
||||
}
|
||||
if ($item['cellSubTypeSort']) {
|
||||
$maxCellSubTypeSort = max($maxCellSubTypeSort, $item['cellSubTypeSort']);
|
||||
}
|
||||
//处理一个单元格中有多个组织的情况
|
||||
foreach ($item['tissue'] as $tissue) {
|
||||
//处理一个单元格中有多个sku的情况
|
||||
foreach ($item['sku'] as $sku) {
|
||||
|
||||
$data[] = [
|
||||
'species'=>$item['species'], 'specieSort'=>$item['specieSort'], 'cellType'=>$item['cellType'],
|
||||
'cellTypeSort'=>$item['cellTypeSort'],'cellSubType'=>$item['cellSubType'], 'cellSubTypeSort'=>$item['cellSubTypeSort'], 'tissue'=>trim($tissue),
|
||||
'positive'=>$item['positive'], 'negative'=>$item['negative'], 'sku'=>trim($sku)
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$maxCellSubTypeSort++;
|
||||
|
||||
foreach ($data as $item) {
|
||||
$output->writeln(sprintf('<info>%s</info>', implode(', ', $item)));
|
||||
}
|
||||
|
||||
$species = $this->speciesResource->getConnection()->fetchAll('select * from '.$this->speciesResource->getMainTable());
|
||||
if (empty($species)) {
|
||||
foreach ($this->getSpecies($data) as $species) {
|
||||
$this->speciesResource->getConnection()->insert($this->speciesResource->getMainTable(), $species);
|
||||
}
|
||||
$species = $this->speciesResource->getConnection()->fetchAll('select * from '.$this->speciesResource->getMainTable());
|
||||
}
|
||||
$speciesIndex = [];
|
||||
foreach ($species as $item) {
|
||||
$speciesIndex[$item['species_name']] = ['species_id'=>$item['species_id'], 'species_sort'=>$item['species_sort']];
|
||||
}
|
||||
unset($species);
|
||||
|
||||
$cellTypes = $this->cellTypeResource->getConnection()->fetchAll('select * from '.$this->cellTypeResource->getMainTable());
|
||||
if (empty($cellTypes)) {
|
||||
foreach ($this->getCellType($data) as $cellType) {
|
||||
$this->cellTypeResource->getConnection()->insert($this->cellTypeResource->getMainTable(), $cellType);
|
||||
}
|
||||
$cellTypes = $this->cellTypeResource->getConnection()->fetchAll('select * from '.$this->cellTypeResource->getMainTable());
|
||||
}
|
||||
$cellTypesIndex = [];
|
||||
foreach ($cellTypes as $item) {
|
||||
$cellTypesIndex[$item['cell_type_name']] = ['cell_type_id'=>$item['cell_type_id'], 'cell_type_sort'=>$item['cell_type_sort']];
|
||||
}
|
||||
|
||||
$cellSubTypes = $this->cellTypeResource->getConnection()->fetchAll('select * from '.$this->cellSubTypeResource->getMainTable());
|
||||
if (empty($cellSubTypes)) {
|
||||
foreach ($cellSubTypeData as $cellType) {
|
||||
if (empty($cellType['cellSubTypeSort'])) {
|
||||
$cellType['cellSubTypeSort'] = $maxCellSubTypeSort;
|
||||
}
|
||||
$this->cellTypeResource->getConnection()->insert(
|
||||
$this->cellSubTypeResource->getMainTable(),
|
||||
[
|
||||
'cell_subtype_name' => $cellType['cellSubType'],
|
||||
'cell_subtype_sort' => $cellType['cellSubTypeSort'],
|
||||
]
|
||||
);
|
||||
}
|
||||
$cellTypes = $this->cellTypeResource->getConnection()->fetchAll('select * from '.$this->cellSubTypeResource->getMainTable());
|
||||
}
|
||||
$cellSubTypesIndex = [];
|
||||
foreach ($cellTypes as $item) {
|
||||
$cellSubTypesIndex[$item['cell_subtype_name']] = $item['cell_subtype_id'];
|
||||
}
|
||||
|
||||
unset($cellSubTypes);
|
||||
|
||||
$tissues = $this->tissueResource->getConnection()->fetchAll('select * from '.$this->tissueResource->getMainTable());
|
||||
if (empty($tissues)) {
|
||||
foreach (array_unique(array_column($data, 'tissue')) as $tissue) {
|
||||
$this->tissueResource->getConnection()->insert($this->tissueResource->getMainTable(), ['tissue_name' => $tissue]);
|
||||
}
|
||||
$tissues = $this->tissueResource->getConnection()->fetchAll('select * from '.$this->tissueResource->getMainTable());
|
||||
}
|
||||
$tissueIndex = [];
|
||||
foreach ($tissues as $item) {
|
||||
$tissueIndex[$item['tissue_name']] = $item['tissue_id'];
|
||||
}
|
||||
|
||||
unset($tissues);
|
||||
|
||||
$cellSorts = $this->cellSortResource->getConnection()->fetchOne('select * from '.$this->cellSortResource->getMainTable());
|
||||
|
||||
if (empty($cellSorts)) {
|
||||
foreach ($data as $item) {
|
||||
$flag = null;
|
||||
if ($item['positive']==1) {
|
||||
$flag = 1;
|
||||
} elseif ($item['negative']==1) {
|
||||
$flag = -1;
|
||||
}
|
||||
$insertData = [
|
||||
'species_id' => $speciesIndex[$item['species']]['species_id'],
|
||||
'species_name' => $item['species'],
|
||||
'species_sort' => $speciesIndex[$item['species']]['species_sort'],
|
||||
'cell_type_id' => $cellTypesIndex[$item['cellType']]['cell_type_id'],
|
||||
'cell_type_sort' => $cellTypesIndex[$item['cellType']]['cell_type_sort'],
|
||||
'cell_type_name' => $item['cellType'],
|
||||
'cell_subtype_id' => $cellSubTypesIndex[$item['cellSubType']],
|
||||
'cell_subtype_name' => $item['cellSubType'],
|
||||
'cell_subtype_sort' => $item['cellSubTypeSort']?? $maxCellSubTypeSort,
|
||||
'tissue_id' => $tissueIndex[$item['tissue']],
|
||||
'tissue_name' => $item['tissue'],
|
||||
'sku' => $this->getParentProduct($item['sku']),
|
||||
'flag' => $flag,
|
||||
];
|
||||
try {
|
||||
$this->cellSortResource->getConnection()->insert($this->cellSortResource->getMainTable(), $insertData);
|
||||
} catch (\Exception $exception) {
|
||||
$output->writeln(
|
||||
'<error>insert data into cell_sort_product exception, </error> '.
|
||||
'exception: '.$exception->getMessage() .', data: '.json_encode($insertData)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
|
||||
use Magento\Framework\Module\Dir;
|
||||
use Stemcell\Catalog\Model\ExperimentalSchemeFactory;
|
||||
use Stemcell\Catalog\Model\ResourceModel\ExperimentalScheme;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
/**
|
||||
* 从excel中导入实验方案数据
|
||||
*/
|
||||
class ExperimentalSchemeImport extends Command
|
||||
{
|
||||
protected $parentProduct = [];
|
||||
|
||||
public function __construct(
|
||||
private Dir $dir,
|
||||
private ExperimentalSchemeFactory $experimentalSchemeFactory,
|
||||
private ExperimentalScheme $experimentalSchemeResource,
|
||||
){
|
||||
parent::__construct('experimental:scheme:import');
|
||||
$this->setDescription('实验方案数据导入');
|
||||
}
|
||||
|
||||
protected function getSpreadsheet()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/experimental-scheme.xlsx';
|
||||
if (!file_exists($path)) {
|
||||
throw new \Exception(sprintf('File %s does not exist', $path));
|
||||
}
|
||||
|
||||
return IOFactory::load($path);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
//清除就数据
|
||||
$this->experimentalSchemeResource->getConnection()->query('TRUNCATE TABLE '.$this->experimentalSchemeResource->getMainTable());
|
||||
|
||||
$spreadsheet = $this->getSpreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$lastRow = $sheet->getHighestRow();
|
||||
|
||||
for ($row = 2; $row <= $lastRow; ++$row) {
|
||||
$collectionName = $sheet->getCell('A' . $row)->getValue();
|
||||
if ($collectionName) {
|
||||
$collectionName = trim($collectionName);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
$collectionSort = intval(trim((string)$sheet->getCell('B' . $row)->getValue()));
|
||||
$title = trim((string)$sheet->getCell('C' . $row)->getValue());
|
||||
$imagePath = $sheet->getCell('D' . $row)->getValue();
|
||||
if ($imagePath) {
|
||||
$imagePath = 'experimental-scheme/images/'.trim($imagePath);
|
||||
}
|
||||
|
||||
$mpUrl = trim((string)$sheet->getCell('E' . $row)->getValue());
|
||||
|
||||
|
||||
$data = [
|
||||
'collection_name'=>$collectionName, 'collection_sort'=>$collectionSort, 'title'=>$title, 'image'=>$imagePath, 'mp_url'=>$mpUrl
|
||||
];
|
||||
$this->experimentalSchemeFactory->create()->setData($data)->save();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use Magento\Catalog\Model\ProductRepository;
|
||||
use Magento\Framework\App\State;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* 从xlsx导入搜索tag, 此命令执行完成后,需要执行indexer:reindex命令
|
||||
* 具体的说明参见README.md 1.0
|
||||
*/
|
||||
class ImportSearchTagsValue extends Command
|
||||
{
|
||||
|
||||
private const NAME_ARGUMENT = "name";
|
||||
private const NAME_OPTION = "option";
|
||||
|
||||
private array $spu = [];
|
||||
|
||||
public function __construct(
|
||||
private Dir $dir,
|
||||
private ProductRepository $productRepository,
|
||||
private State $state,
|
||||
) {
|
||||
parent::__construct('stemcell:product:import-search-tag-value');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
*/
|
||||
protected function getExcelReader()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/Current Website Product Model Number.xlsx';
|
||||
if (!file_exists($path)) {
|
||||
throw new \Exception(sprintf('File %s does not exist', $path));
|
||||
}
|
||||
return IOFactory::createReader('Xlsx')->load($path);
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function execute(
|
||||
InputInterface $input,
|
||||
OutputInterface $output
|
||||
): int {
|
||||
try {
|
||||
$worksheet = $this->getExcelReader()->getActiveSheet();
|
||||
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
|
||||
foreach ($worksheet->getRowIterator() as $row) {
|
||||
$rowIndex = $row->getRowIndex();
|
||||
if ($rowIndex === 1) {
|
||||
continue;
|
||||
}
|
||||
$sku = $worksheet->getCell('A'.$rowIndex)->getValue();
|
||||
try {
|
||||
$searchTag = $worksheet->getCell('B'.$rowIndex)->getValue();
|
||||
|
||||
if (empty($searchTag)) {
|
||||
continue;
|
||||
}
|
||||
$product = $this->productRepository->get($sku);
|
||||
if ($product->getData('search_tags') && str_contains($product->getData('search_tags'), $searchTag)) {
|
||||
$output->writeln(sprintf('<info>search tags %s already set for product: %s</info>', $searchTag, $sku));
|
||||
}
|
||||
|
||||
$output->writeln(sprintf('product %s search tags: %s', $sku, $searchTag));
|
||||
$product->addAttributeUpdate('search_tags', $searchTag, 1);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(sprintf('<error>import search tags value fail:%s, product: %s</error>', $e->getMessage(), $sku));
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(sprintf('<error>import search tags value exception: %s</error>', $e->getMessage()));
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->setDescription("从xlsx导入搜索tag, 此命令执行完成后,需要执行indexer:reindex命令");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use Magento\Catalog\Model\ProductRepository;
|
||||
use Magento\Framework\App\State;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* 从xlsx导入search term, 此命令执行前需要确保\Stemcell\Catalog\Setup\Patch\Schema\AddSearchTermsProductAttribute已经执行
|
||||
* 此命令执行完成后,需要确认索引(index)刷新了
|
||||
*
|
||||
* 具体的说明参见README.md 2.0
|
||||
*/
|
||||
class ImportSearchTermsValue extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private Dir $dir,
|
||||
private ProductRepository $productRepository,
|
||||
private State $state,
|
||||
) {
|
||||
parent::__construct('stemcell:product:import-search-terms');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
*/
|
||||
protected function getExcelReader()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/Search Terms.xlsx';
|
||||
if (!file_exists($path)) {
|
||||
throw new \Exception(sprintf('File %s does not exist', $path));
|
||||
}
|
||||
return IOFactory::createReader('Xlsx')->load($path);
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function execute(
|
||||
InputInterface $input,
|
||||
OutputInterface $output
|
||||
): int {
|
||||
try {
|
||||
$worksheet = $this->getExcelReader()->getActiveSheet();
|
||||
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
|
||||
foreach ($worksheet->getRowIterator() as $row) {
|
||||
$rowIndex = $row->getRowIndex();
|
||||
if ($rowIndex === 1) {
|
||||
continue;
|
||||
}
|
||||
$sku = $worksheet->getCell('A'.$rowIndex)->getValue();
|
||||
try {
|
||||
$originalSearchTerms = (string)$worksheet->getCell('B'.$rowIndex)->getValue();
|
||||
$originalSearchTerms = trim($originalSearchTerms);
|
||||
|
||||
if (empty($originalSearchTerms)) {
|
||||
continue;
|
||||
}
|
||||
$originalSearchTerms = str_replace('|', '|', $originalSearchTerms);
|
||||
$searchTerms = '';
|
||||
foreach (explode('|', $originalSearchTerms) as $term) {
|
||||
$searchTerms .= preg_replace('/\s+/', '', $term).'|';
|
||||
}
|
||||
if (strcasecmp($originalSearchTerms, $searchTerms) != 0) {
|
||||
$searchTerms = $searchTerms.$originalSearchTerms;
|
||||
}
|
||||
|
||||
$product = $this->productRepository->get($sku);
|
||||
// if ($product->getData('search_terms') && str_contains($product->getData('search_terms'), $searchTag)) {
|
||||
// $output->writeln(sprintf('<info>search terms %s already set for product: %s</info>', $searchTag, $sku));
|
||||
// }
|
||||
|
||||
$output->writeln(sprintf('product %s search terms: %s', $sku, $searchTerms));
|
||||
$product->addAttributeUpdate('search_terms', $searchTerms, 0);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(sprintf('<error>import search terms value fail:%s, product: %s</error>', $e->getMessage(), $sku));
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(sprintf('<error>import search terms value exception: %s</error>', $e->getMessage()));
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->setDescription("从xlsx导入search terms, 此命令执行完成后,需要执行indexer:reindex命令");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use Magento\Catalog\Model\ProductRepository;
|
||||
use Magento\Framework\App\State;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ImportSearchWordValue extends Command
|
||||
{
|
||||
|
||||
private const NAME_ARGUMENT = "name";
|
||||
private const NAME_OPTION = "option";
|
||||
|
||||
private array $spu = [];
|
||||
|
||||
public function __construct(
|
||||
private Dir $dir,
|
||||
private ProductRepository $productRepository,
|
||||
private State $state,
|
||||
) {
|
||||
parent::__construct('stemcell:catalog:import-search-word-value');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
*/
|
||||
protected function getExcelReader()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/search_words.xlsx';
|
||||
if (!file_exists($path)) {
|
||||
throw new \Exception(sprintf('File %s does not exist', $path));
|
||||
}
|
||||
return IOFactory::createReader('Xlsx')->load($path);
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function execute(
|
||||
InputInterface $input,
|
||||
OutputInterface $output
|
||||
): int {
|
||||
try {//100-1723_C
|
||||
$worksheet = $this->getExcelReader()->getActiveSheet();
|
||||
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
|
||||
foreach ($worksheet->getRowIterator() as $row) {
|
||||
$rowIndex = $row->getRowIndex();
|
||||
$spu = $worksheet->getCell('A'.$rowIndex)->getValue();
|
||||
try {
|
||||
$searchWords = $worksheet->getCell('C'.$rowIndex)->getValue();
|
||||
if (empty($searchWords) || in_array($spu, $this->spu)) {
|
||||
continue;
|
||||
}
|
||||
$product = $this->productRepository->get($spu);
|
||||
$output->writeln(sprintf('product %s search word: %s', $spu, $product->getData('search_words')));
|
||||
$product->addAttributeUpdate('search_words', $searchWords, 1);
|
||||
$this->spu[] = $spu;
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(sprintf('<error>import search word value fail:%s, product: %s</error>', $e->getMessage(), $spu));
|
||||
}
|
||||
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(sprintf('<error>import search word value exception: %s</error>', $e->getMessage()));
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->setDescription("Test script");
|
||||
$this->setDefinition([
|
||||
new InputArgument(self::NAME_ARGUMENT, InputArgument::OPTIONAL, "Name"),
|
||||
new InputOption(self::NAME_OPTION, "-a", InputOption::VALUE_NONE, "Option functionality")
|
||||
]);
|
||||
parent::configure();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Framework\App\State;
|
||||
use Magento\Framework\Console\Cli;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ParentSkuNameImport extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private ProductRepositoryInterface $productRepository,
|
||||
private readonly Dir $dir,
|
||||
private readonly State $state,
|
||||
) {
|
||||
$name = 'product:parent_sku:name:import';
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
protected function getSpreadsheet()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/PIS.xlsx';
|
||||
if (!file_exists($path)) {
|
||||
throw new \Exception(sprintf('File %s does not exist', $path));
|
||||
}
|
||||
|
||||
return IOFactory::load($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$spreadsheet = $this->getSpreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$lastRow = $sheet->getHighestRow();
|
||||
|
||||
$this->state->setAreaCode('adminhtml');
|
||||
|
||||
$notExistSku = [];
|
||||
for ($row = 2; $row <= $lastRow; ++$row) {
|
||||
$pisSku = trim((string)$sheet->getCell('A' . $row)->getValue());
|
||||
$parentsProduct = [
|
||||
[
|
||||
'sku'=>trim((string)$sheet->getCell('B' . $row)->getValue()),
|
||||
'name'=>trim((string)$sheet->getCell('C' . $row)->getValue()),
|
||||
],
|
||||
[
|
||||
'sku'=>trim((string)$sheet->getCell('D' . $row)->getValue()),
|
||||
'name'=>trim((string)$sheet->getCell('E' . $row)->getValue()),
|
||||
]
|
||||
];
|
||||
try {
|
||||
$pisProduct = $this->productRepository->get($pisSku, true);
|
||||
$skus = [];
|
||||
foreach ($parentsProduct as $parentProduct) {
|
||||
if ($parentProduct['sku']) {
|
||||
try {
|
||||
$product = $this->productRepository->get($parentProduct['sku'], true);
|
||||
$product->setName($parentProduct['name']);
|
||||
$this->productRepository->save($product);
|
||||
$skus[] = $parentProduct['sku'];
|
||||
} catch (NoSuchEntityException $e) {
|
||||
if (!in_array($parentProduct['sku'], $notExistSku)) {
|
||||
$notExistSku[] = $parentProduct['sku'];
|
||||
}
|
||||
$output->writeln(sprintf('<error>产品: %s 不存在</error>', $parentProduct['sku']));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($skus)) {
|
||||
$parentSku = implode(',', $skus);
|
||||
if ($pisProduct->getData('parent_skus')) {
|
||||
$originParentSku = explode(',', $pisProduct->getData('parent_skus'));
|
||||
$parentSku = implode(',', array_unique(array_merge($originParentSku, $skus)));
|
||||
}
|
||||
$pisProduct->setData('parent_skus', $parentSku);
|
||||
$this->productRepository->save($pisProduct);
|
||||
}
|
||||
|
||||
}catch (\Exception $exception){
|
||||
$output->writeln(sprintf(' <error>PIS: %s </error>导入时发生异常:%s', $pisSku,$exception->getMessage()));
|
||||
}
|
||||
}
|
||||
$output->writeln(sprintf('<error>产品不存在的SKU: %s</error>', implode(',', $notExistSku)));
|
||||
return Cli::RETURN_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use Stemcell\Catalog\Model\ProductManualSearch;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Catalog\Model\Category;
|
||||
|
||||
class ProductManualSearchImport extends Command
|
||||
{
|
||||
const PRODUCT_SHEET_CATEGORY_URL_KEY = 'product-information-sheets';
|
||||
private int $productSheetCategoryId = 0;
|
||||
|
||||
public function __construct(
|
||||
private ProductResource $productResource,
|
||||
private ProductResource\CollectionFactory $productCollectionFactory,
|
||||
private Category $category,
|
||||
private ProductManualSearch $productManualSearch,
|
||||
) {
|
||||
parent::__construct('product:manual:search:import');
|
||||
$this->setDescription('导入产品说明书搜索数据');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getDataSource()
|
||||
{
|
||||
$sql = "
|
||||
SELECT catalog_product_entity_varchar.`value` as sku, catalog_product_entity.sku as search_sku
|
||||
FROM catalog_product_entity_varchar
|
||||
LEFT JOIN catalog_product_entity on catalog_product_entity.entity_id=catalog_product_entity_varchar.entity_id
|
||||
WHERE catalog_product_entity_varchar.`value` is not NULL and catalog_product_entity_varchar.attribute_id=
|
||||
(SELECT attribute_id FROM eav_attribute WHERE attribute_code='parent_skus')
|
||||
";
|
||||
return $this->productResource->getConnection()->fetchAll($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
protected function getProductSheetCategoryId()
|
||||
{
|
||||
if (!$this->productSheetCategoryId){
|
||||
$category = $this->category->loadByAttribute('url_key', self::PRODUCT_SHEET_CATEGORY_URL_KEY);
|
||||
$this->productSheetCategoryId = $category? intval($category->getId()) : 0;
|
||||
}
|
||||
return $this->productSheetCategoryId;
|
||||
}
|
||||
/**
|
||||
* @param array $skus
|
||||
* @return ProductResource\Collection
|
||||
*/
|
||||
protected function getProductFromSkus(array $skus){
|
||||
return $this->productCollectionFactory->create()->addAttributeToSelect('name', true)->addCategoryIds()
|
||||
->addAttributeToFilter('sku', ['in' => $skus]);
|
||||
}
|
||||
|
||||
protected function addNewRecord(array $record)
|
||||
{
|
||||
if (isset($record['name']) && isset($record['sku']) && isset($record['search_sku'])) {
|
||||
$sql = "INSERT INTO product_manual_search (name, sku, search_sku) select \"".$record['name']."\",'".$record['sku']
|
||||
."','".$record['search_sku'].'\' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM product_manual_search WHERE sku="'.$record['sku'].'" and search_sku="'.$record['search_sku'].'")';
|
||||
|
||||
// echo "\r\n";
|
||||
// echo $sql."\r\n";
|
||||
$this->productResource->getConnection()->query($sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function doRun()
|
||||
{
|
||||
foreach ($this->getDataSource() as $product) {
|
||||
foreach ($this->getProductFromSkus(explode(',', $product['sku'])) as $item) {
|
||||
/* @var $item Product */
|
||||
$data = ['name' => $item->getName(), 'sku' => $item->getSku(), 'search_sku' => $product['search_sku']];
|
||||
$this->addNewRecord($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
//$this->productResource->getConnection()->query('TRUNCATE TABLE product_manual_search');
|
||||
|
||||
$this->doRun();
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\CategoryRepository;
|
||||
use Magento\Framework\Api\FilterBuilder;
|
||||
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Magento\Catalog\Helper\Product as ProductHelper;
|
||||
|
||||
class ProductSimpleExport extends Command
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private array $category = [];
|
||||
|
||||
public function __construct(
|
||||
private ProductRepositoryInterface $productRepository,
|
||||
private SearchCriteriaBuilder $searchCriteriaBuilder,
|
||||
private FilterBuilder $filterBuilder,
|
||||
private CategoryRepository $categoryRepository,
|
||||
private ProductHelper $productHelper,
|
||||
private DirectoryList $directoryList
|
||||
) {
|
||||
parent::__construct('stemcell:product:simple_export');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $categoryId
|
||||
* @return string
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
protected function getCategory(int $categoryId) {
|
||||
if (!$categoryId) {
|
||||
return '';
|
||||
}
|
||||
if (!isset($this->category[$categoryId])) {
|
||||
$category = $this->categoryRepository->get($categoryId);
|
||||
$this->category[$categoryId] = $category->getName()??'';
|
||||
}
|
||||
|
||||
return $this->category[$categoryId];
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$filePath = $this->directoryList->getPath(DirectoryList::VAR_DIR) . '/export/product.xlsx';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->getColumnDimension('A')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('B')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('C')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('D')->setAutoSize(true);
|
||||
$sheet->getColumnDimension('E')->setAutoSize(true);
|
||||
$sheet->getStyle('1')->getFont()->setBold(true);
|
||||
|
||||
$sheet->setCellValueExplicit('A1', '主货号', DataType::TYPE_STRING)
|
||||
->setCellValue('B1', 'Product Type')
|
||||
->setCellValue('C1', '产品中文名')
|
||||
->setCellValue('D1', '产品英文名')
|
||||
->setCellValue('E1', '链接');
|
||||
|
||||
$criteria = $this->searchCriteriaBuilder->addFilter(
|
||||
$this->filterBuilder->setField('type_id')->setValue('configurable')->create()
|
||||
)
|
||||
->addFilter(
|
||||
$this->filterBuilder->setField('status')->setValue(1)->create()
|
||||
)
|
||||
// ->addFilter(
|
||||
// $this->filterBuilder->setField('search_words')->setConditionType('notnull')->create()
|
||||
// )
|
||||
->create();
|
||||
$sheet->getRowDimension(1)->setRowHeight(20);
|
||||
$key = 2;
|
||||
foreach ($this->productRepository->getList($criteria)->getItems() as $item) {
|
||||
if (!str_contains($item->getSku(), '_C')) {
|
||||
continue;
|
||||
}
|
||||
$categories = $item->getCategoryIds();
|
||||
$catIds = (int)end($categories);
|
||||
if (count($categories) > 3) {
|
||||
$catIds = $categories[2];
|
||||
}
|
||||
$sheet->getRowDimension($key)->setRowHeight(20);
|
||||
$sheet->setCellValue('A'.$key, $item->getSku())
|
||||
->setCellValue('B'.$key, $this->getCategory($catIds))
|
||||
->setCellValue('C'.$key, $item->getName())
|
||||
->setCellValue('D'.$key, $item->getSearchWords())
|
||||
->setCellValue('E'.$key, $this->productHelper->getProductUrl($item));
|
||||
|
||||
$key++;
|
||||
}
|
||||
$writer = IOFactory::createWriter($spreadsheet, IOFactory::READER_XLSX);
|
||||
$writer->save($filePath);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Catalog\Model\ProductRepository;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\App\State;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\FileSystemException;
|
||||
use Magento\Framework\Exception\InputException;
|
||||
use Magento\Framework\Exception\StateException;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
|
||||
|
||||
/**
|
||||
* 更新产品详情的产品说明书及文档中PDF的URL,如果PDF在服务器上存在,就用当前域名替换pdf的域名。
|
||||
*/
|
||||
class ProtocolsDocumentationPdfUpdate extends Command
|
||||
{
|
||||
private OutputInterface $output;
|
||||
private string $baseUrl;
|
||||
|
||||
private array $notExistPdf = [];
|
||||
|
||||
public function __construct(
|
||||
private ProductCollection $productCollection,
|
||||
private DirectoryList $directoryList,
|
||||
private UrlInterface $url,
|
||||
private ProductRepository $productRepository,
|
||||
private State $state,
|
||||
private \Magento\Store\Model\StoreManagerInterface $storeManager,
|
||||
) {
|
||||
parent::__construct('protocols:documentation:update');
|
||||
}
|
||||
|
||||
protected function updatePdfUrl(Product $product){
|
||||
|
||||
$html = $product->getData('protocols_documentation');
|
||||
$html = preg_replace('/<\/?body[^>]*>/i', '', $html);
|
||||
|
||||
$dom = new \DOMDocument();
|
||||
libxml_use_internal_errors(true); // 避免 HTML 解析警告
|
||||
$dom->loadHTML(mb_encode_numericentity($html, [0x80, 0x10FFFF, 0, ~0], 'UTF-8'));
|
||||
|
||||
libxml_clear_errors();
|
||||
|
||||
$links = $dom->getElementsByTagName('a');
|
||||
|
||||
foreach ($links as $link) {
|
||||
$href = $link->getAttribute('href');
|
||||
|
||||
// $output->writeln('old pdf href: ' . $href);
|
||||
|
||||
if ($href && preg_match('/\.pdf$/i', $href)) {
|
||||
|
||||
$pdfPath = parse_url($href, PHP_URL_PATH);
|
||||
|
||||
$pdfPath = $this->directoryList->getPath(DirectoryList::PUB).'/'.$pdfPath;
|
||||
|
||||
// 检查 PDF 是否存在
|
||||
if (file_exists($pdfPath)) {
|
||||
$this->output->writeln(sprintf('product %s old pdf href: %s', $product->getSku(), $href));
|
||||
$newUrl = preg_replace(
|
||||
'#^https?://[^/]+/#i',
|
||||
$this->baseUrl,
|
||||
$href
|
||||
);
|
||||
$this->output->writeln(sprintf('<info>product %s updated pdf href: %s</info>', $product->getSku(), $newUrl));
|
||||
// 更新 <a> 标签的 href
|
||||
$link->setAttribute('href', $newUrl);
|
||||
} else {
|
||||
$md5 = md5(strtolower($href));
|
||||
if (!isset($this->notExistPdf[$md5])) {
|
||||
$this->notExistPdf[$md5] = $href;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$body = $dom->getElementsByTagName("body")->item(0);
|
||||
|
||||
return $dom->saveHTML($body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function exportNotExistPdf()
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$sheet->getStyle('A1:' . 'B1')->getFont()->setBold(true);
|
||||
$sheet->setCellValue('A1', 'pdf links');
|
||||
|
||||
$rowIndex = 2;
|
||||
foreach ($this->notExistPdf as $link) {
|
||||
|
||||
// $sheet->setCellValue('B' . $rowIndex, implode("\n", $links));
|
||||
$sheet->getStyle('A' . $rowIndex)->getAlignment()->setWrapText(true);
|
||||
$sheet->setCellValueExplicit('A' . $rowIndex, $link, DataType::TYPE_STRING);
|
||||
|
||||
$sheet->getColumnDimension('A')->setWidth(100);
|
||||
$rowIndex++;
|
||||
}
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$pdfPath = $this->directoryList->getPath(DirectoryList::VAR_DIR).'/share/产品说明书及文档不存在的PDF-'.date('Ymd').'.xlsx';
|
||||
$writer->save($pdfPath);
|
||||
}
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
|
||||
|
||||
$this->output = $output;
|
||||
$this->baseUrl = $this->url->getBaseUrl();
|
||||
|
||||
foreach ($this->storeManager->getStores(true) as $store) {
|
||||
$collection = $this->productCollection
|
||||
->setStoreId($store->getId())
|
||||
->addAttributeToFilter('protocols_documentation', ['neq' => 'NULL']);
|
||||
|
||||
foreach ($collection as $product) {
|
||||
// if ($product->getSku()=='100-0237_C') {
|
||||
// $output->writeln(preg_replace('/<\/?body[^>]*>/i', '', $product->getData('protocols_documentation')));
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
$output->writeln(sprintf('product: %s', $product->getSku()));
|
||||
$html = preg_replace('/<\/?body[^>]*>/i', '', $this->updatePdfUrl($product));
|
||||
// $output->writeln('updated html: ');
|
||||
// $output->writeln($html);
|
||||
// $output->writeln('');
|
||||
$product->setData('protocols_documentation', $html);
|
||||
try {
|
||||
$product->setData('_edit_mode', true);
|
||||
$product->setStoreId($store->getId());
|
||||
$this->productRepository->save($product);
|
||||
} catch (\Exception $e) {
|
||||
$this->output->writeln(sprintf('<error>product %s updated pdf fail, msg: %s</error>', $product->getSku(), $e->getMessage()));
|
||||
}
|
||||
// if ($product->getSku()=='100-0237_C') {
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
$this->exportNotExistPdf();
|
||||
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use Magento\Catalog\Model\ProductRepository;
|
||||
use Magento\Framework\App\State;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\InputException;
|
||||
use Magento\Framework\Exception\StateException;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ProtocolsDocumentationRepair extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private ProductCollectionFactory $productCollectionFactory,
|
||||
private ProductRepository $productRepository,
|
||||
private State $state,
|
||||
)
|
||||
{
|
||||
parent::__construct('protocols:documentation:repair');
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
|
||||
|
||||
$store0Collection = $this->productCollectionFactory->create()
|
||||
->setStoreId(0)
|
||||
->addAttributeToFilter('protocols_documentation', ['neq' => 'NULL'])
|
||||
->load();
|
||||
|
||||
$store1Collection = $this->productCollectionFactory->create()
|
||||
->setStoreId(1)
|
||||
->addAttributeToFilter('protocols_documentation', ['neq' => 'NULL'])
|
||||
->load();
|
||||
|
||||
foreach ($store1Collection as $item) {
|
||||
/* @var $item \Magento\Catalog\Model\Product */
|
||||
|
||||
/* @var $product \Magento\Catalog\Model\Product */
|
||||
$product = $store0Collection->getItemById($item->getId());
|
||||
$output->writeln('store 1 product: '. $item->getSku());
|
||||
$output->writeln('store 0 product: '. $product->getSku());
|
||||
$output->writeln('');
|
||||
// $output->writeln('store 1 protocols_documentation:');
|
||||
// $output->writeln($item->getData('protocols_documentation'));
|
||||
//
|
||||
// $output->writeln('store 0 protocols_documentation:');
|
||||
// $output->writeln($product->getData('protocols_documentation'));
|
||||
$item->setData('protocols_documentation', $product->getData('protocols_documentation'));
|
||||
$item->setData('_edit_mode', true);
|
||||
try {
|
||||
$this->productRepository->save($item);
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln('product: '.$item->getSku().'exception: <error> '.$e->getMessage().'</error>');
|
||||
}
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
|
||||
use Magento\Framework\App\ResourceConnection;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use Stemcell\Catalog\Model\CryopreserveFactory;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
/**
|
||||
* 从excel中导入数据
|
||||
*/
|
||||
class SampleCryopreserveImport extends Command
|
||||
{
|
||||
protected $parentProduct = [];
|
||||
/**
|
||||
* @var ResourceConnection
|
||||
*/
|
||||
private $resource;
|
||||
public function __construct(
|
||||
private Dir $dir,
|
||||
private CryopreserveFactory $cryopreserveFactory,
|
||||
ResourceConnection $resource,
|
||||
){
|
||||
parent::__construct('sample:cryopreserve:import');
|
||||
$this->setDescription('样本冻存参考小工具数据导入');
|
||||
$this->resource = $resource;
|
||||
}
|
||||
|
||||
protected function getSpreadsheet()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/sample-cryopreserve.xlsx';
|
||||
if (!file_exists($path)) {
|
||||
throw new \Exception(sprintf('File %s does not exist', $path));
|
||||
}
|
||||
|
||||
return IOFactory::load($path);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
//删除旧数据
|
||||
$connection = $this->resource->getConnection()->query('TRUNCATE TABLE cryopreserve');
|
||||
|
||||
$spreadsheet = $this->getSpreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$lastRow = $sheet->getHighestRow();
|
||||
|
||||
for ($row = 2; $row <= $lastRow; ++$row) {
|
||||
$sample = $sheet->getCell('A' . $row)->getValue();
|
||||
if ($sample) {
|
||||
$sample = trim($sample);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
$type = trim((string)$sheet->getCell('B' . $row)->getValue());
|
||||
$cellType = $sheet->getCell('C' . $row)->getValue();
|
||||
if ($cellType) {
|
||||
$cellType = trim($cellType);
|
||||
}
|
||||
|
||||
$referenceDensity = $sheet->getCell('D' . $row)->getValue();
|
||||
$desc = $sheet->getCell('E' . $row)->getValue();
|
||||
if ($desc) {
|
||||
$desc = str_replace("\n", '<br/>', $desc);
|
||||
}
|
||||
|
||||
$references = [];
|
||||
foreach (explode("\n", (string)$sheet->getCell('F' . $row)->getValue()) as $reference) {
|
||||
$references[] = preg_replace('/\d+[\.\。]\s+/', '', $reference);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sample'=>$sample, 'type'=>$type, 'cell_type'=>$cellType,
|
||||
'reference_density'=>$referenceDensity, 'desc'=>$desc, 'reference'=>json_encode($references)
|
||||
];
|
||||
$this->cryopreserveFactory->create()->setData($data)->save();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Console\Command;
|
||||
|
||||
use LanguageDetector\LanguageDetector;
|
||||
use Magento\Catalog\Model\ProductRepository;
|
||||
use Magento\Cms\Model\Template\FilterProvider;
|
||||
use Magento\Framework\App\Config\Storage\WriterInterface as ConfigWriter;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Framework\App\State;
|
||||
use Magento\Framework\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use phpseclib3\Crypt\Common\SymmetricKey;
|
||||
use Stemcell\Datacollection\Cron\FormRecordsNotification;
|
||||
use Stemcell\ProductImport\Console\Command\ExtractDescriptionFromProductDataCSV;
|
||||
use Stemcell\ProductImport\Cron\ImportPrice;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use phpseclib3\Crypt\AES;
|
||||
use phpseclib3\Crypt\Common\BlockCipher;
|
||||
use Magento\Framework\App\Cache\TypeListInterface;
|
||||
|
||||
class Test extends Command
|
||||
{
|
||||
const NO_PRICE_SKU_PATH = 'catalog/product_settings/no_price_sku';
|
||||
public function __construct(
|
||||
private FormRecordsNotification $formRecordsNotification,
|
||||
private DirectoryList $directoryList,
|
||||
protected ImportPrice $importStock,
|
||||
protected ConfigWriter $configWriter,
|
||||
protected TypeListInterface $cacheTypeList,
|
||||
protected TimezoneInterface $timezone,
|
||||
protected FilterProvider $filterProvider,
|
||||
protected StoreManagerInterface $storeManager,
|
||||
protected ProductRepository $productRepository,
|
||||
protected State $state
|
||||
)
|
||||
{
|
||||
$name = 'test';
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
public function getMediaUrl()
|
||||
{
|
||||
return $this->storeManager
|
||||
->getStore()
|
||||
->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
|
||||
}
|
||||
|
||||
protected function isDirEmpty($dir) {
|
||||
if (!is_dir($dir)) {
|
||||
return false; // 或者抛出异常
|
||||
}
|
||||
|
||||
$files = scandir($dir);
|
||||
// 减去 . 和 .. 后,如果数量为0,则文件夹为空
|
||||
return count($files) == 2; // 2 表示只有 . 和 ..
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// $this->formRecordsNotification->execute();
|
||||
// $output->writeln($this->directoryList->getPath('media'));
|
||||
// $content = "Hello world !";
|
||||
// $ivStr128 = "1234567812345678"; // 16字节
|
||||
// $AESSecretGCM256 = "IhHEhIvTS8zbVTY391GP8oHJ7RmSJ8pQ"; // 32字节
|
||||
// $output->writeln(self::encryptGCMWithPhpseclib($content, $AESSecretGCM256, $ivStr128));
|
||||
// $output->writeln($this->timezone->date()->format('Y-m-d H:i:s'));
|
||||
|
||||
$this->state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
|
||||
$product = $this->productRepository->get('MRDX20359', true);
|
||||
$existingEntries = $product->getMediaGalleryEntries();
|
||||
|
||||
if (!empty($existingEntries)) {
|
||||
$output->writeln(" 清理现有图片,共 " . count($existingEntries) . " 张");
|
||||
|
||||
// 清空媒体库条目
|
||||
$product->setMediaGalleryEntries([]);
|
||||
|
||||
// 清除图片角色
|
||||
$product->setImage(null);
|
||||
$product->setSmallImage(null);
|
||||
$product->setThumbnail(null);
|
||||
$this->productRepository->save($product);
|
||||
// $output->writeln(" 现有图片清理完成");
|
||||
}
|
||||
// $this->configWriter->save(
|
||||
// self::NO_PRICE_SKU_PATH,
|
||||
// '111111111111111111111',
|
||||
// ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
|
||||
// 0
|
||||
// );
|
||||
// $this->cacheTypeList->cleanType('config');
|
||||
// $this->importStock->execute();
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
public static function encryptGCMWithPhpseclib($content, $key, $iv)
|
||||
{
|
||||
$cipher = new AES('gcm');
|
||||
$cipher->setPreferredEngine(SymmetricKey::ENGINE_OPENSSL_GCM);
|
||||
$cipher->setKey($key);
|
||||
$cipher->setNonce($iv);
|
||||
$cipher->setKeyLength(256); // 尝试设置256位标签
|
||||
|
||||
$cipherText = $cipher->encrypt($content);
|
||||
$tag = $cipher->getTag();
|
||||
|
||||
// 打包数据
|
||||
$ivLength = pack('N', strlen($iv));
|
||||
$byteBuffer = $ivLength . $iv . $cipherText . $tag;
|
||||
|
||||
return base64_encode($byteBuffer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Controller\Adminhtml\Price;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Import extends \Magento\Backend\App\Action implements HttpGetActionInterface
|
||||
{
|
||||
const ADMIN_RESOURCE = 'Stemcell_Catalog::catalog_index';
|
||||
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
protected PageFactory $resultPageFactory
|
||||
)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute view action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->resultPageFactory->create();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Controller\Adminhtml\Price;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\Collection;
|
||||
use Magento\CatalogInventory\Api\StockRegistryInterface;
|
||||
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableProductType;
|
||||
use Magento\Framework\App\Action\HttpPostActionInterface;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\Exception\FileSystemException;
|
||||
use Magento\Framework\Filesystem\Driver\File;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use Magento\InventoryApi\Api\Data\SourceItemInterfaceFactory;
|
||||
use Magento\InventoryApi\Api\SourceItemsSaveInterface;
|
||||
use Magento\MediaStorage\Model\File\UploaderFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\ProductImport\Model\Import\TypeId;
|
||||
use Stemcell\ProductImport\Model\ImportTaskFactory;
|
||||
use Magento\Indexer\Model\Indexer\CollectionFactory as IndexerCollectionFactory;
|
||||
use Stemcell\ProductImport\Model\ResourceModel\ImportTask as ImportTaskResource;
|
||||
|
||||
/**
|
||||
* 由于生产服务器是两台,只有media目录是两台服务器共享,因此将文件上传到media下面
|
||||
*/
|
||||
class ImportPost extends \Magento\Backend\App\Action implements HttpPostActionInterface
|
||||
{
|
||||
private UploaderFactory $fileUploaderFactory;
|
||||
private Filesystem\Directory\WriteInterface $mediaDirectory;
|
||||
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
UploaderFactory $fileUploaderFactory,
|
||||
Filesystem $filesystem,
|
||||
File $driverFile,
|
||||
protected ProductRepositoryInterface $productRepository,
|
||||
protected LoggerInterface $logger,
|
||||
protected Collection $collection,
|
||||
protected Dir $dir,
|
||||
protected SourceItemsSaveInterface $sourceItemsSave,
|
||||
protected SourceItemInterfaceFactory $sourceItemFactory,
|
||||
protected ConfigurableProductType $configurableProductType,
|
||||
protected StockRegistryInterface $stockRegistry,
|
||||
protected IndexerCollectionFactory $indexerCollectionFactory,
|
||||
protected ImportTaskFactory $importTaskFactory,
|
||||
protected ImportTaskResource $importTaskResource,
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->fileUploaderFactory = $fileUploaderFactory;
|
||||
$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$fileUploader = $this->fileUploaderFactory->create([
|
||||
'fileId' => 'stock[import]'
|
||||
]);
|
||||
|
||||
$fileUploader->setAllowedExtensions(['xls', 'xlsx']);
|
||||
$fileUploader->setAllowRenameFiles(true);
|
||||
$fileUploader->setAllowCreateFolders(true);
|
||||
$fileUploader->setFilesDispersion(false);
|
||||
|
||||
$dir = $this->mediaDirectory->getAbsolutePath(DirectoryList::VAR_IMPORT_EXPORT.'/stock');
|
||||
!is_dir($dir) && mkdir($dir, 0755, true);
|
||||
$fileUploader->save($dir);
|
||||
$importTask = $this->importTaskFactory->create()->setData([
|
||||
'file_path' => $dir.'/'.$fileUploader->getUploadedFileName(),
|
||||
'type_id' => TypeId::PRICE->value,
|
||||
]);
|
||||
|
||||
$this->importTaskResource->save($importTask);
|
||||
$this->messageManager->addSuccessMessage(__('产品价格导入任务创建成功.'));
|
||||
return $this->resultRedirectFactory->create()->setPath('stemcell_catalog/price/index');
|
||||
} catch (LocalizedException | \Exception $error) {
|
||||
$this->logger->critical($error);
|
||||
$this->messageManager->addErrorMessage('产品价格导入任务创建失败. 原因:'.$error->getMessage());
|
||||
return $this->resultRedirectFactory->create()->setPath('stemcell_catalog/price/import');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Controller\Adminhtml\Price;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends \Magento\Backend\App\Action implements HttpGetActionInterface
|
||||
{
|
||||
const ADMIN_RESOURCE = 'Stemcell_Catalog::catalog_index';
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
protected PageFactory $resultPageFactory
|
||||
)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute view action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->resultPageFactory->create();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Controller\Adminhtml\Price;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
|
||||
class Sample extends \Magento\Backend\App\Action implements HttpGetActionInterface
|
||||
{
|
||||
protected \Magento\Framework\App\Response\Http\FileFactory $fileFactory;
|
||||
private \Magento\Framework\Module\Dir $moduleDir;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
|
||||
\Magento\Framework\Module\Dir $moduleDir,
|
||||
Context $context
|
||||
) {
|
||||
$this->fileFactory = $fileFactory;
|
||||
$this->moduleDir = $moduleDir;
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$file = $this->moduleDir->getDir('Stemcell_Catalog').'/data/sample/price.xlsx';
|
||||
$content['type'] = 'filename';
|
||||
$content['value'] = $file;
|
||||
$content['rm'] = 0;
|
||||
return $this->fileFactory->create('price.xlsx', $content);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Controller\Adminhtml\Stock;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Import extends \Magento\Backend\App\Action implements HttpGetActionInterface
|
||||
{
|
||||
const ADMIN_RESOURCE = 'Stemcell_Catalog::catalog_index';
|
||||
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
protected PageFactory $resultPageFactory
|
||||
)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute view action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->resultPageFactory->create();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Controller\Adminhtml\Stock;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\Collection;
|
||||
use Magento\CatalogInventory\Api\StockRegistryInterface;
|
||||
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableProductType;
|
||||
use Magento\Framework\App\Action\HttpPostActionInterface;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\Exception\FileSystemException;
|
||||
use Magento\Framework\Filesystem\Driver\File;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use Magento\InventoryApi\Api\Data\SourceItemInterfaceFactory;
|
||||
use Magento\InventoryApi\Api\SourceItemsSaveInterface;
|
||||
use Magento\MediaStorage\Model\File\UploaderFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\ProductImport\Model\Import\TypeId;
|
||||
use Stemcell\ProductImport\Model\ImportTaskFactory;
|
||||
use Magento\Indexer\Model\Indexer\CollectionFactory as IndexerCollectionFactory;
|
||||
use Stemcell\ProductImport\Model\ResourceModel\ImportTask as ImportTaskResource;
|
||||
|
||||
/**
|
||||
* 由于生产服务器是两台,只有media目录是两台服务器共享,因此将文件上传到media下面
|
||||
*/
|
||||
class ImportPost extends \Magento\Backend\App\Action implements HttpPostActionInterface
|
||||
{
|
||||
private UploaderFactory $fileUploaderFactory;
|
||||
private Filesystem\Directory\WriteInterface $mediaDirectory;
|
||||
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
UploaderFactory $fileUploaderFactory,
|
||||
Filesystem $filesystem,
|
||||
File $driverFile,
|
||||
protected ProductRepositoryInterface $productRepository,
|
||||
protected LoggerInterface $logger,
|
||||
protected Collection $collection,
|
||||
protected Dir $dir,
|
||||
protected SourceItemsSaveInterface $sourceItemsSave,
|
||||
protected SourceItemInterfaceFactory $sourceItemFactory,
|
||||
protected ConfigurableProductType $configurableProductType,
|
||||
protected StockRegistryInterface $stockRegistry,
|
||||
protected IndexerCollectionFactory $indexerCollectionFactory,
|
||||
protected ImportTaskFactory $importTaskFactory,
|
||||
protected ImportTaskResource $importTaskResource,
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->fileUploaderFactory = $fileUploaderFactory;
|
||||
$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$jsonResult = $this->resultFactory->create(ResultFactory::TYPE_JSON);
|
||||
try {
|
||||
$fileUploader = $this->fileUploaderFactory->create([
|
||||
'fileId' => 'stock[import]'
|
||||
]);
|
||||
|
||||
$fileUploader->setAllowedExtensions(['xls', 'xlsx']);
|
||||
$fileUploader->setAllowRenameFiles(true);
|
||||
$fileUploader->setAllowCreateFolders(true);
|
||||
$fileUploader->setFilesDispersion(false);
|
||||
|
||||
$dir = $this->mediaDirectory->getAbsolutePath(DirectoryList::VAR_IMPORT_EXPORT.'/stock');
|
||||
!is_dir($dir) && mkdir($dir, 0755, true);
|
||||
$fileUploader->save($dir);
|
||||
$importTask = $this->importTaskFactory->create()->setData([
|
||||
'file_path' => $dir.'/'.$fileUploader->getUploadedFileName(),
|
||||
'type_id' => $this->_request->getParam('type_id', TypeId::STOCK->value),
|
||||
]);
|
||||
|
||||
$this->importTaskResource->save($importTask);
|
||||
$this->messageManager->addSuccessMessage(__('库存导入任务创建成功.'));
|
||||
return $this->resultRedirectFactory->create()->setPath('stemcell_catalog/stock/index');
|
||||
} catch (LocalizedException | \Exception $error) {
|
||||
$this->logger->critical($error);
|
||||
$this->messageManager->addErrorMessage('库存导入任务创建失败. 原因:'.$error->getMessage());
|
||||
return $this->resultRedirectFactory->create()->setPath('stemcell_catalog/stock/import');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Controller\Adminhtml\Stock;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends \Magento\Backend\App\Action implements HttpGetActionInterface
|
||||
{
|
||||
const ADMIN_RESOURCE = 'Stemcell_Catalog::catalog_index';
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
protected PageFactory $resultPageFactory
|
||||
)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute view action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->resultPageFactory->create();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Controller\Adminhtml\Stock;
|
||||
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
|
||||
class Sample extends \Magento\Backend\App\Action implements HttpGetActionInterface
|
||||
{
|
||||
protected \Magento\Framework\App\Response\Http\FileFactory $fileFactory;
|
||||
private \Magento\Framework\Module\Dir $moduleDir;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
|
||||
\Magento\Framework\Module\Dir $moduleDir,
|
||||
\Magento\Backend\App\Action\Context $context
|
||||
) {
|
||||
$this->fileFactory = $fileFactory;
|
||||
$this->moduleDir = $moduleDir;
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$file = $this->moduleDir->getDir('Stemcell_Catalog').'/data/sample/stock.xlsx';
|
||||
$content['type'] = 'filename';
|
||||
$content['value'] = $file;
|
||||
$content['rm'] = 0;
|
||||
return $this->fileFactory->create('stock.xlsx', $content);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Enum;
|
||||
|
||||
enum CategoryOption: string
|
||||
{
|
||||
case Products = 'Products';
|
||||
case Resources = 'Resources';
|
||||
case Documents = 'Documents';
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Helper;
|
||||
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\ConfigurableProduct\Block\Product\View\Type\Configurable;
|
||||
use \Magento\ConfigurableProduct\Helper\Data as ConfigurableProductHelper;
|
||||
|
||||
class Configuration
|
||||
{
|
||||
public function __construct(
|
||||
private Configurable $configurableBlock,
|
||||
private ConfigurableProductHelper $configurableProductHelper,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* get configurable attribute associated product
|
||||
* @param Product $product
|
||||
* @return array|mixed []
|
||||
*/
|
||||
public function getConfigurableAttributeProducts(Product $product) {
|
||||
$this->configurableBlock->setProduct($product);
|
||||
$options = $this->configurableProductHelper->getOptions($product, $this->configurableBlock->getAllowProducts());
|
||||
return $options['salable'] ?? [];
|
||||
}
|
||||
|
||||
protected function getProductAttributesIdByCode(Product $product, array $attributeCodes)
|
||||
{
|
||||
$attributesId = [];
|
||||
foreach ($product->getAttributes() as $attribute) {
|
||||
if (in_array($attribute->getAttributeCode(), $attributeCodes)) {
|
||||
$attributesId[] = $attribute->getAttributeId();
|
||||
}
|
||||
}
|
||||
return $attributesId;
|
||||
}
|
||||
|
||||
public function extractContentBetweenPTag(string $content)
|
||||
{
|
||||
if ($content) {
|
||||
preg_match('/<p>(.*?)<\/p>/', $content, $matches);
|
||||
return isset($matches[1]) ? $matches[1] : $content;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get product images for configurable variations
|
||||
* @param Product $configurableProduct
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionImages(Product $configurableProduct)
|
||||
{
|
||||
$images = [];
|
||||
$shortDescription = [];
|
||||
|
||||
$allProducts = $configurableProduct->getTypeInstance()
|
||||
->setStoreFilter($configurableProduct->getStoreId(), $configurableProduct)
|
||||
->getUsedProducts($configurableProduct, null);
|
||||
|
||||
foreach ($allProducts as $product) {
|
||||
/* @var $product Product */
|
||||
$product->load($product->getId());
|
||||
foreach ($product->getMediaGalleryImages() as $image) {
|
||||
|
||||
$images[$product->getId()][] =
|
||||
[
|
||||
'file' => $image->getFile(),
|
||||
'label' => $image->getLabel(),
|
||||
'position' => $image->getPosition(),
|
||||
'types' => $image->getTypes(),
|
||||
'url' => $product->getMediaConfig()->getMediaUrl($image->getFile())
|
||||
];
|
||||
}
|
||||
|
||||
$shortDescription[$product->getId()]['short_description'] =
|
||||
$this->extractContentBetweenPTag($product->getData('feature'));
|
||||
$shortDescription[$product->getId()]['sku'] = $product->getSku();
|
||||
}
|
||||
|
||||
return [$images, $shortDescription];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Helper;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
class Excel
|
||||
{
|
||||
/**
|
||||
* @param string $filePath 文件路径
|
||||
* @return \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getExcelSheet(string $filePath)
|
||||
{
|
||||
if (!file_exists($filePath)) {
|
||||
throw new \Exception(sprintf('File %s does not exist', $filePath));
|
||||
}
|
||||
|
||||
return IOFactory::load($filePath)->getActiveSheet();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Helper\Product;
|
||||
|
||||
use Magento\Catalog\Api\Data\ProductInterface;
|
||||
use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager;
|
||||
use Magento\Catalog\Model\Product\Type;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\View\Result\Page as ResultPage;
|
||||
use Stemcell\SubItemProduct\Model\ResourceModel\SubItem\CollectionFactory;
|
||||
use Stemcell\SubItemProduct\Model\SubItem as SubItemModel;
|
||||
|
||||
class View extends \Magento\Catalog\Helper\Product\View
|
||||
{
|
||||
const STOCK_CHECK_GROUP_PATH = 'stemcell_web/catalog/stock_check_group';
|
||||
|
||||
public function __construct(
|
||||
\Magento\Framework\App\Helper\Context $context,
|
||||
\Magento\Catalog\Model\Session $catalogSession,
|
||||
\Magento\Catalog\Model\Design $catalogDesign,
|
||||
\Magento\Catalog\Helper\Product $catalogProduct,
|
||||
\Magento\Framework\Registry $coreRegistry,
|
||||
\Magento\Framework\Message\ManagerInterface $messageManager,
|
||||
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator,
|
||||
protected CollectionFactory $subItemCollectionFactory,
|
||||
protected \Magento\Customer\Model\Session $customerSession,
|
||||
array $messageGroups = [],
|
||||
\Magento\Framework\Stdlib\StringUtils $string = null,
|
||||
?LayoutUpdateManager $layoutUpdateManager = null
|
||||
) {
|
||||
parent::__construct(
|
||||
$context,
|
||||
$catalogSession,
|
||||
$catalogDesign,
|
||||
$catalogProduct,
|
||||
$coreRegistry,
|
||||
$messageManager,
|
||||
$categoryUrlPathGenerator,
|
||||
$messageGroups,
|
||||
$string,
|
||||
$layoutUpdateManager
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init layout for viewing product page
|
||||
*
|
||||
* @param \Magento\Framework\View\Result\Page $resultPage
|
||||
* @param \Magento\Catalog\Model\Product $product
|
||||
* @param null|\Magento\Framework\DataObject $params
|
||||
* @return \Magento\Catalog\Helper\Product\View
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*/
|
||||
public function initProductLayout(ResultPage $resultPage, $product, $params = null)
|
||||
{
|
||||
parent::initProductLayout($resultPage, $product, $params);
|
||||
$pageConfig = $resultPage->getConfig();
|
||||
if ($product->getTypeId()=== Type::TYPE_VIRTUAL) {
|
||||
$pageConfig->addBodyClass('virtual-product-video');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据大货号(简单产品或可配置产品的子产品)的的库存计算出产品的库存量
|
||||
* @return int
|
||||
*/
|
||||
public function getStockFromSubItems(ProductInterface $product){
|
||||
if ($product->getTypeId() != Type::TYPE_SIMPLE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$collection = $this->subItemCollectionFactory->create()->setItemObjectClass(SubItemModel::class)
|
||||
->addFieldToFilter('product_id', $product->getId());
|
||||
if(!$collection->getSize()){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* @var $subItem SubItemModel */
|
||||
foreach ($collection as $subItem){
|
||||
if ($subItem->getStockQty()==0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
$stocks = [];
|
||||
foreach ($collection as $subItem){
|
||||
$bundleQty = $subItem->getBundleQty()==0? 1 : $subItem->getBundleQty();
|
||||
$stocks[] = floor($subItem->getStockQty() / $bundleQty);
|
||||
}
|
||||
|
||||
return min($stocks);
|
||||
}
|
||||
|
||||
public function notStockCheckGroup()
|
||||
{
|
||||
try {
|
||||
return $this->customerSession->isLoggedIn()
|
||||
&& $this->customerSession->getCustomerGroupId() != $this->scopeConfig->getValue(self::STOCK_CHECK_GROUP_PATH);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,619 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Api;
|
||||
|
||||
use Magento\Catalog\Model\Product\Attribute\Source\Status;
|
||||
use Magento\Catalog\Model\Product\Type as ProductType;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Framework\Webapi\Rest\Request;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Stemcell\Catalog\Helper\Excel;
|
||||
use Magento\Eav\Model\Config as EavConfig;
|
||||
use Stemcell\Catalog\Setup\Patch\Data\AddChineseEditionCellSeparationOption;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
|
||||
|
||||
/**
|
||||
* 分选说明书接口
|
||||
*/
|
||||
class CellSeparation
|
||||
{
|
||||
public function __construct(
|
||||
private Dir $dir,
|
||||
private StoreManagerInterface $storeManager,
|
||||
private Request $restRequest,
|
||||
protected EavConfig $eavConfig,
|
||||
protected ProductCollectionFactory $productCollectionFactory,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Worksheet $sheet
|
||||
* @param string $cell
|
||||
* @return string
|
||||
*/
|
||||
protected function getCellValue(Worksheet $sheet, string $cell)
|
||||
{
|
||||
return trim((string)$sheet->getCell($cell)->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
protected function getResourceTypeChinesePisOptionId()
|
||||
{
|
||||
$attribute = $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'resource_type');
|
||||
$attribute->setStoreId(0);
|
||||
$optionId = 0;
|
||||
foreach ($attribute->getOptions() as $option) {
|
||||
if ($option->getLabel() == AddChineseEditionCellSeparationOption::RESOURCE_TYPE_ENGLISH_LABEL) {
|
||||
$optionId = (int)$option->getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $optionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分选说明书接口
|
||||
* @return string
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$pageSize = 10;
|
||||
$page = $this->restRequest->getParam('page', 1);
|
||||
$start = ($page - 1) * $pageSize;
|
||||
|
||||
$keyword = trim($this->restRequest->getParam('keyword', ''));
|
||||
|
||||
$isSku = preg_match('/^\d+[A-Za-z]*$/', $keyword) !==0 ;
|
||||
//['sku' => $sku, 'label' => $name, 'pdf'=>$mediaUrl.$pdfPath, 'url'=>$mediaUrl.$sku.'/'.$pdfPath]
|
||||
$data = [];
|
||||
$mediaUrl = $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_WEB);
|
||||
$chinesePisCollection = $this->productCollectionFactory->create()
|
||||
->addAttributeToSelect(['parent_skus', 'document_path', 'parent_names'])
|
||||
->addAttributeToFilter('status', Status::STATUS_ENABLED)
|
||||
->addAttributeToFilter('type_id', ProductType::TYPE_VIRTUAL)
|
||||
->addAttributeToFilter('resource_type', $this->getResourceTypeChinesePisOptionId());
|
||||
|
||||
if ($keyword) {
|
||||
$chinesePisCollection->addAttributeToFilter([
|
||||
['attribute' => 'parent_skus', 'finset' => $keyword],
|
||||
['attribute' => 'parent_names', 'like' => '%'.$keyword.'%'],
|
||||
]);
|
||||
}
|
||||
|
||||
$parentSkus = '';
|
||||
foreach ($chinesePisCollection as $item) {
|
||||
|
||||
$parentSkus .= $item->getData('parent_skus').',';
|
||||
}
|
||||
$parentSkus = trim($parentSkus, ',');
|
||||
|
||||
$productNames = [];
|
||||
$collection = $this->productCollectionFactory->create()
|
||||
->addAttributeToSelect(['name'])
|
||||
->addAttributeToFilter('status', Status::STATUS_ENABLED)
|
||||
->addAttributeToFilter('sku', ['in' => array_unique(explode(',', $parentSkus))]);
|
||||
foreach ($collection as $item) {
|
||||
$productNames[$item->getSku()] = $item->getName();
|
||||
}
|
||||
|
||||
foreach ($chinesePisCollection as $item) {
|
||||
|
||||
$pdfPath = $mediaUrl.ltrim($item->getData('document_path'), '/');
|
||||
if ($item->getData('parent_skus')) {
|
||||
foreach (explode(',', $item->getData('parent_skus')) as $sku) {
|
||||
if (($isSku && $keyword && $sku && strtolower($keyword)==strtolower($sku))
|
||||
|| (!$isSku && $item->getData('parent_names') && str_contains(strtolower($item->getData('parent_names')), strtolower($keyword)))) {
|
||||
if (isset($productNames[$sku])){
|
||||
$data[$item->getSku()] = [
|
||||
'sku' => $sku,
|
||||
'label' => $productNames[$sku],
|
||||
'pdf'=>ltrim($pdfPath, '/'),
|
||||
'url'=>ltrim($pdfPath, '/')
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = array_values($data);
|
||||
$count = count($data);
|
||||
// $pages = ceil($count / $pageSize);
|
||||
// $page = min($page, $pages);
|
||||
// $end = $page * $pageSize - 1;
|
||||
// $rows = [];
|
||||
// foreach ($data as $index => $row) {
|
||||
// if ($index >= $start && $index <= $end) {
|
||||
// $rows[] = $row;
|
||||
// }
|
||||
// if ($index > $end) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
$result = [
|
||||
'items' => $data,
|
||||
'filter_code' => 'keyword',
|
||||
'filters' => [],
|
||||
'pages' => $page,
|
||||
'total_count' => $count,
|
||||
];
|
||||
return json_encode($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Api;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Framework\Api\FilterBuilder;
|
||||
use Magento\Framework\Api\SearchCriteriaBuilder;
|
||||
use Magento\Framework\Webapi\Rest\Request as RestRequest;
|
||||
use Stemcell\Catalog\Api\Data\CellSortSearchResultsInterface;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellSort\Collection as CellSortCollection;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellSort\CollectionFactory as CellSortCollectionFactory;
|
||||
use Stemcell\Catalog\Model\ResourceModel\Species\Collection as SpeciesCollection;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellType\Collection as CellTypeCollection;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellSubType\Collection as CellSubTypeCollection;
|
||||
use Stemcell\Catalog\Model\ResourceModel\Tissue\Collection as TissueCollection;
|
||||
|
||||
/**
|
||||
* 此接口依赖cell:sort:import命令和app/code/Stemcell/Catalog/data/cell-select-tool.xlsx。
|
||||
* 如果ell-select-tool.xlsx中的数据有改动,就需要重新跑cell:sort:import命令
|
||||
*/
|
||||
class CellSortTool
|
||||
{
|
||||
protected array $labels = [
|
||||
'species' => '物种',
|
||||
'cellTypes' => '细胞',
|
||||
'cellSubTypes' => '细胞亚型',
|
||||
'tissues' => '样本',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private CellSortCollection $cellSortCollection,
|
||||
private CellSortCollectionFactory $cellSortCollectionFactory,
|
||||
private RestRequest $restRequest,
|
||||
private ProductRepositoryInterface $productRepository,
|
||||
private CellSortSearchResultsInterface $cellSortSearchResults,
|
||||
private SearchCriteriaBuilder $searchCriteriaBuilder,
|
||||
private SpeciesCollection $speciesCollection,
|
||||
private CellTypeCollection $cellTypeCollection,
|
||||
private CellSubTypeCollection $cellSubTypeCollection,
|
||||
private TissueCollection $tissueCollection,
|
||||
) {
|
||||
}
|
||||
|
||||
protected function addFilter()
|
||||
{
|
||||
$species = intval($this->restRequest->getParam('species'));
|
||||
$cellTypeId = intval($this->restRequest->getParam('cellTypes'));
|
||||
$cellSubTypeId = intval($this->restRequest->getParam('cellSubTypes'));
|
||||
$tissueId = intval($this->restRequest->getParam('tissues'));
|
||||
|
||||
if ($species) {
|
||||
$this->cellSortCollection->addFieldToFilter('species_id', $species);
|
||||
}
|
||||
if ($cellTypeId) {
|
||||
$this->cellSortCollection->addFieldToFilter('cell_type_id', $cellTypeId);
|
||||
}
|
||||
if ($cellSubTypeId) {
|
||||
$this->cellSortCollection->addFieldToFilter('cell_subtype_id', $cellSubTypeId);
|
||||
}
|
||||
if ($tissueId) {
|
||||
$this->cellSortCollection->addFieldToFilter('tissue_id', $tissueId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function getSpecies()
|
||||
{
|
||||
$species = [];
|
||||
$items = $this->speciesCollection->setOrder('species_sort', 'asc')->load()->getItems();
|
||||
foreach ($items as $specie) {
|
||||
|
||||
/* @var $specie \Stemcell\Catalog\Model\Species */
|
||||
$species[$specie->getSpeciesId()] = $specie->toArray();
|
||||
}
|
||||
return $species;
|
||||
}
|
||||
|
||||
protected function getCellTypes()
|
||||
{
|
||||
$speciesId = intval($this->restRequest->getParam('species'));
|
||||
$data = [];
|
||||
if ($speciesId) {
|
||||
$cellTypes = $this->cellSortCollectionFactory->create()->addFieldToFilter('species_id', $speciesId)->setOrder('cell_type_sort', 'asc');
|
||||
foreach ($cellTypes as $cellType) {
|
||||
/* @var $cellType \Stemcell\Catalog\Model\CellSort */
|
||||
if (!isset($data[$cellType->getCellTypeId()])) {
|
||||
$data[$cellType->getCellTypeId()] = ['cell_type_id' => $cellType->getCellTypeId(), 'cell_type_name' => $cellType->getCellTypeName(), 'cell_type_sort'=>$cellType->getData('cell_type_sort')];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data = $this->cellTypeCollection->setOrder('cell_type_sort', 'asc')->load()->getData();
|
||||
}
|
||||
return array_values($data);
|
||||
}
|
||||
|
||||
protected function getCellSubTypes()
|
||||
{
|
||||
$cellTypesId = intval($this->restRequest->getParam('cellTypes'));
|
||||
$speciesId = intval($this->restRequest->getParam('species'));
|
||||
$data = [];
|
||||
if ($cellTypesId) {
|
||||
$cellTypes = $this->cellSortCollectionFactory->create()
|
||||
->addFieldToFilter('species_id', $speciesId)
|
||||
->addFieldToFilter('cell_type_id', $cellTypesId)
|
||||
->setOrder('cell_subtype_sort', 'asc');
|
||||
foreach ($cellTypes as $cellType) {
|
||||
/* @var $cellType \Stemcell\Catalog\Model\CellSort */
|
||||
if (!isset($data[$cellType->getCellSubTypeId()])) {
|
||||
$data[$cellType->getCellSubTypeId()] = ['cell_subtype_id' => $cellType->getCellSubTypeId(), 'cell_subtype_name' => $cellType->getCellSubTypeName()];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data = $this->cellSubTypeCollection->setOrder('cell_subtype_sort', 'asc')->load()->getData();
|
||||
}
|
||||
return array_values($data);
|
||||
}
|
||||
|
||||
protected function getTissues()
|
||||
{
|
||||
$cellTypesId = intval($this->restRequest->getParam('cellTypes'));
|
||||
$speciesId = intval($this->restRequest->getParam('species'));
|
||||
$cellSubTypeId = intval($this->restRequest->getParam('cellSubTypes'));
|
||||
$data = [];
|
||||
|
||||
if ($cellSubTypeId) {
|
||||
$cellTypes = $this->cellSortCollectionFactory->create()
|
||||
->addFieldToFilter('species_id', $speciesId)
|
||||
->addFieldToFilter('cell_type_id', $cellTypesId)
|
||||
->addFieldToFilter('cell_subtype_id', $cellSubTypeId);
|
||||
foreach ($cellTypes as $cellType) {
|
||||
/* @var $cellType \Stemcell\Catalog\Model\CellSort */
|
||||
if (!isset($data[$cellType->getTissueId()])) {
|
||||
$data[$cellType->getTissueId()] = ['tissue_id' => $cellType->getTissueId(), 'tissue_name' => $cellType->getTissueName()];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data = $this->tissueCollection->load()->getData();
|
||||
}
|
||||
|
||||
return array_values($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
*/
|
||||
private function getFilters()
|
||||
{
|
||||
$species = $this->getSpecies();
|
||||
|
||||
return ['species' => array_values($species), 'cellTypes' => $this->getCellTypes(), 'cellSubTypes' => $this->getCellSubTypes(), 'tissues' => $this->getTissues()];
|
||||
}
|
||||
/**
|
||||
* @return \Stemcell\Catalog\Api\Data\CellSortSearchResultsInterface
|
||||
*/
|
||||
public function getProducts() {
|
||||
|
||||
$this->addFilter();
|
||||
$skus = $flags = [];
|
||||
foreach ($this->cellSortCollection as $cellSort) {
|
||||
/* @var $cellSort \Stemcell\Catalog\Model\CellSort */
|
||||
|
||||
if (!isset($skus[$cellSort->getSku()])) {
|
||||
$skus[$cellSort->getSku()] = $cellSort->getSku();
|
||||
}
|
||||
if (!isset($flags[$cellSort->getSku()])) {
|
||||
$flags[$cellSort->getSku()] = $cellSort->getFlag();
|
||||
}
|
||||
}
|
||||
|
||||
$pageSize = 10;
|
||||
$page = intval($this->restRequest->getParam('page'));
|
||||
$criteria = $this->searchCriteriaBuilder
|
||||
->addFilter('sku', $skus, 'in')
|
||||
->addFilter('visibility', [2,3,4], 'in')
|
||||
->setPageSize($pageSize)
|
||||
->setCurrentPage($page)
|
||||
->create();
|
||||
$products = $this->productRepository->getList($criteria);
|
||||
foreach ($products->getItems() as $product) {
|
||||
$sku = $product->getSku();
|
||||
$product->getExtensionAttributes()?->setCellFlag(isset($flags[$sku]) && $flags[$sku]==1? true:false);
|
||||
}
|
||||
return $this->cellSortSearchResults->setFilters(json_encode($this->getFilters()))
|
||||
->setLabels(json_encode($this->labels))
|
||||
->setItems($products->getItems())
|
||||
->setTotalCount($products->getTotalCount());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Api\Data;
|
||||
|
||||
use Magento\Framework\Api\SearchResults;
|
||||
use Stemcell\Catalog\Api\Data\CellSortSearchResultsInterface;
|
||||
|
||||
class CellSortSearchResults extends SearchResults implements CellSortSearchResultsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return $this->_get(self::FILTERS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setFilters(string $filters)
|
||||
{
|
||||
return $this->setData(self::FILTERS, $filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLabels()
|
||||
{
|
||||
return $this->_get(self::LABELS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setLabels(string $labels)
|
||||
{
|
||||
return $this->setData(self::LABELS, $labels);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Api\Data;
|
||||
|
||||
use Stemcell\Catalog\Api\Data\ProductListWithFilterInterface;
|
||||
use Magento\Framework\Api\SearchResults;
|
||||
|
||||
class ProductListWithFilter extends SearchResults implements ProductListWithFilterInterface
|
||||
{
|
||||
const FILTERS = 'filters';
|
||||
const FILTER_CODE = 'filterCode';
|
||||
|
||||
/**
|
||||
* @param string $filter
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilters(string $filter)
|
||||
{
|
||||
$this->setData(self::FILTERS, $filter);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
if (empty($this->_get(self::FILTERS))) {
|
||||
$this->setData(self::FILTERS, []);
|
||||
}
|
||||
|
||||
return $this->_get(self::FILTERS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filterCode
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilterCode(string $filterCode)
|
||||
{
|
||||
$this->setData(self::FILTER_CODE, $filterCode);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFilterCode()
|
||||
{
|
||||
return (string)$this->_get(self::FILTER_CODE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Api;
|
||||
|
||||
use Magento\Framework\Webapi\Rest\Request as RestRequest;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Stemcell\Catalog\Model\ResourceModel\ExperimentalScheme\CollectionFactory as CollectionFactory;
|
||||
|
||||
/**
|
||||
* 实验方案
|
||||
*/
|
||||
class ExperimentalScheme
|
||||
{
|
||||
const PAGE_SIZE = 10;
|
||||
public function __construct(
|
||||
private RestRequest $restRequest,
|
||||
private CollectionFactory $collectionFactory,
|
||||
private StoreManagerInterface $storeManager,
|
||||
) {
|
||||
}
|
||||
|
||||
protected function getFilters() : array
|
||||
{
|
||||
$collection = $this->collectionFactory->create();
|
||||
$table = $collection->getMainTable();
|
||||
$rows = $collection->getConnection()->fetchAll(
|
||||
'select MIN(collection_name) AS collection_name, collection_sort from '.$table
|
||||
.' group by collection_sort order by collection_sort asc'
|
||||
);
|
||||
$data = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$data[] = ['collection_name'=>$row['collection_name']];
|
||||
}
|
||||
|
||||
return array_values($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$collectionName = trim((string)$this->restRequest->getParam('collection'));
|
||||
$page = intval($this->restRequest->getParam('page', 1));
|
||||
$collection = $this->collectionFactory->create();
|
||||
if (!empty($collectionName)) {
|
||||
$collection->addFieldToFilter('collection_name', $collectionName);
|
||||
}
|
||||
$collection->setPageSize(self::PAGE_SIZE)->setCurPage($page)->setOrder('collection_sort', 'asc');
|
||||
$mediaUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
|
||||
$data = $collection->getData();
|
||||
foreach ($data as &$item) {
|
||||
$item['image'] = $mediaUrl . $item['image'];
|
||||
}
|
||||
return json_encode([
|
||||
'data'=>['items' => $data, 'total_count'=>$collection->getSize()],
|
||||
'filters' => ['collection'=>$this->getFilters()]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Api;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Layer\Category as CategoryLayer;
|
||||
use Magento\Catalog\Model\Layer\Resolver;
|
||||
use Magento\Framework\Api\FilterBuilder;
|
||||
use Magento\Framework\Api\SearchCriteriaBuilder;
|
||||
use Magento\Framework\Api\SortOrder;
|
||||
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
|
||||
use Magento\Framework\Api\Search\SearchInterface;
|
||||
use \Magento\Framework\Api\Search\SearchCriteriaInterface;
|
||||
use Magento\Framework\Api\Search\FilterGroupBuilder;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Module\Dir;
|
||||
use Magento\Framework\Webapi\Rest\Request;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Stemcell\Catalog\Helper\Configuration as ConfigurationHelper;
|
||||
use Magento\Eav\Model\Config as EavConfig;
|
||||
use Stemcell\Catalog\Api\Data\ProductListWithFilterInterface;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Stemcell\Catalog\Helper\Excel;
|
||||
use \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Stemcell\Catalog\Model\ProductManualSearch;
|
||||
use Stemcell\Catalog\Setup\Patch\Data\AddChineseEditionCellSeparationOption;
|
||||
|
||||
class Product
|
||||
{
|
||||
private CategoryLayer $_categoryLayer;
|
||||
|
||||
private array $filters = [
|
||||
'e-book' => ['attribute' => 'area_of_interest', 'optionsLabel' => ['免疫', '嵌合体', '类器官', '脐带血库', 'HLA']],
|
||||
'product-information-sheets' => ['attribute' => 'resource_type', 'optionsLabel' => ['产品信息表', '技术手册']],
|
||||
'protocol' => ['attribute' => 'area_of_interest', 'optionsLabel' =>
|
||||
[
|
||||
'上皮细胞研究', '免疫', '内皮细胞研究', '呼吸系统研究', '干细胞生物学', '感染性疾病(传染病)', '疾病建模', '癌症',
|
||||
'神经科学', '类器官', '细胞治疗开发', '细胞系制备', '药物发现和毒理检测'
|
||||
]
|
||||
],
|
||||
'product-manual' => ['attribute' => 'area_of_interest', 'optionsLabel' =>
|
||||
[
|
||||
'HIV', '上皮细胞研究', '免疫', '内皮细胞研究', '呼吸系统研究', '嵌合体', '干细胞生物学', '感染性疾病(传染病)',
|
||||
'抗体制备', '杂交瘤制备', '疾病建模', '癌症', '神经科学', '移植研究', '类器官', '细胞治疗开发', '细胞系制备',
|
||||
'脐带血库', '药物发现和毒理检测', '血管生成细胞研究', 'HLA'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private ProductRepositoryInterface $productRepository,
|
||||
private SearchCriteriaBuilder $searchCriteriaBuilder,
|
||||
private FilterBuilder $filterBuilder,
|
||||
private SearchInterface $search,
|
||||
private SearchCriteriaInterface $searchCriteria,
|
||||
private FilterGroupBuilder $filterGroupBuilder,
|
||||
private ConfigurationHelper $configurationHelper,
|
||||
private SortOrder $sortOrder,
|
||||
private Resolver $layerResolver,
|
||||
private Request $restRequest,
|
||||
private EavConfig $eavConfig,
|
||||
private ProductListWithFilterInterface $productListWithFilter,
|
||||
private ProductCollectionFactory $productCollectionFactory,
|
||||
private Dir $dir,
|
||||
private StoreManagerInterface $storeManager,
|
||||
private ProductManualSearch $productManualSearch,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $categoryId
|
||||
* @param int $page
|
||||
* @return \Magento\Catalog\Api\Data\ProductSearchResultsInterface
|
||||
*/
|
||||
public function getList(int $categoryId, int $page = 1)
|
||||
{
|
||||
$statusFilter = $this->filterBuilder
|
||||
->setField('status')
|
||||
->setConditionType('eq')
|
||||
->setValue(1)
|
||||
->create();
|
||||
|
||||
$visibilityFilter = $this->filterBuilder
|
||||
->setField('visibility')
|
||||
->setConditionType('in')
|
||||
->setValue([2,3,4])
|
||||
->create();
|
||||
|
||||
$categoryFilter = $this->filterBuilder
|
||||
->setField('category_id')
|
||||
->setConditionType('eq')
|
||||
->setValue($categoryId)
|
||||
->create();
|
||||
|
||||
$criteria = $this->searchCriteriaBuilder
|
||||
->addFilters([$visibilityFilter, $categoryFilter])
|
||||
->setPageSize(10)
|
||||
->setCurrentPage($page)
|
||||
->addSortOrder($this->sortOrder->setField('entity_id')->setDirection('DESC'))
|
||||
->create();
|
||||
return $this->productRepository->getList($criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sku
|
||||
* @return \Magento\Catalog\Api\Data\ProductInterface|void
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getBySku(string $sku){
|
||||
|
||||
$product = $this->productRepository->get($sku);
|
||||
|
||||
if ($product->getTypeId() == Configurable::TYPE_CODE) {
|
||||
$attributes = $this->configurationHelper->getConfigurableAttributeProducts($product);
|
||||
|
||||
/* @var $productTypeInstance \Magento\ConfigurableProduct\Model\Product\Type\Configurable */
|
||||
$productTypeInstance = $product->getTypeInstance();
|
||||
$configurableAttributes = $productTypeInstance->getConfigurableAttributesAsArray($product);
|
||||
|
||||
foreach ($product->getExtensionAttributes()->getConfigurableProductOptions() as $option) {
|
||||
|
||||
$options = array_column($option->getOptions(), null, 'value_index');
|
||||
if (isset($configurableAttributes[$option->getAttributeId()])) {
|
||||
$option->setLabel($configurableAttributes[$option->getAttributeId()]['frontend_label']);
|
||||
}
|
||||
foreach ($option->getValues() as $value) {
|
||||
if (isset($options[$value->getValueIndex()])) {
|
||||
$value->getExtensionAttributes()
|
||||
->setLabel($options[$value->getValueIndex()]['label'])
|
||||
->setProducts($attributes[$option->getAttributeId()][$value->getValueIndex()]??[]);
|
||||
}
|
||||
}
|
||||
}
|
||||
list($childrenImages, $childrenDescription) = $this->configurationHelper->getOptionImages($product);
|
||||
$product->getExtensionAttributes()
|
||||
->setChildrenImages(json_encode($childrenImages))
|
||||
->setChildrenShortDescription(json_encode($childrenDescription));
|
||||
}
|
||||
|
||||
return $product;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $term
|
||||
* @param int $page
|
||||
* @return \Magento\Catalog\Api\Data\ProductSearchResultsInterface
|
||||
*/
|
||||
public function search(string $term, int $page = 1)
|
||||
{
|
||||
$pageSize = 10;
|
||||
$termFilter = $this->filterBuilder
|
||||
->setField('search_term')
|
||||
->setValue($term)
|
||||
->setConditionType('like')
|
||||
->create();
|
||||
|
||||
$criteria = $this->searchCriteria
|
||||
->setFilterGroups([$this->filterGroupBuilder->addFilter($termFilter)->create()])
|
||||
->setRequestName('quick_search_container');
|
||||
|
||||
$result = $this->search->search($criteria);
|
||||
$productIds = [];
|
||||
|
||||
foreach ($result->getItems() as $product) {
|
||||
/* @var $product \Magento\Framework\Api\Search\Document */
|
||||
if ($product->getCustomAttribute('score')->getValue() < 10) {
|
||||
continue;
|
||||
}
|
||||
$productIds[] = $product->getId();
|
||||
}
|
||||
|
||||
$filter = $this->filterBuilder
|
||||
->setField('entity_id')
|
||||
->setConditionType('in')
|
||||
->setValue(array_values($productIds))
|
||||
->create();
|
||||
$criteria = $this->searchCriteriaBuilder
|
||||
->addFilters([$filter])
|
||||
->setPageSize($pageSize)
|
||||
->setCurrentPage($page)
|
||||
->create();
|
||||
|
||||
return $this->productRepository->getList($criteria);
|
||||
}
|
||||
|
||||
protected function getProductOptions(string $attribute, array $optionsLabel)
|
||||
{
|
||||
$attribute = $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attribute);
|
||||
$options = [];
|
||||
|
||||
foreach ($attribute->getSource()->getAllOptions() as $option) {
|
||||
|
||||
if (in_array($option['label'], $optionsLabel)) {
|
||||
$options[] = $option;
|
||||
}
|
||||
}
|
||||
return [$options, $attribute->getFrontendInput() == 'multiselect'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据产品说明书分类下的产品parent_skus, 获取对应产品的name、sku,通过parents返回给前端显示
|
||||
* @param ProductCollection $productCollection
|
||||
* @return void
|
||||
*/
|
||||
protected function setParent(ProductCollection $productCollection)
|
||||
{
|
||||
foreach ($productCollection as $product) {
|
||||
|
||||
/* @var $product \Magento\Catalog\Api\Data\ProductInterface */
|
||||
if ($parentSkus = $product->getData('parent_skus')) {
|
||||
$collection = $this->productCollectionFactory->create()->addAttributeToSelect('name')
|
||||
->addAttributeToFilter('sku', ['in' => explode(',', $parentSkus)]);
|
||||
$parents = [];
|
||||
foreach ($collection as $item) {
|
||||
$parents[] = ['sku' => $item->getSku(), 'name' => $item->getName()];
|
||||
}
|
||||
|
||||
$product->getExtensionAttributes()->setParents(json_encode($parents));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
protected function getResourceTypeChinesePisOptionId()
|
||||
{
|
||||
$attribute = $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'resource_type');
|
||||
$attribute->setStoreId(0);
|
||||
$optionId = 0;
|
||||
foreach ($attribute->getOptions() as $option) {
|
||||
if ($option->getLabel() == AddChineseEditionCellSeparationOption::RESOURCE_TYPE_ENGLISH_LABEL) {
|
||||
$optionId = (int)$option->getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $optionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序技术资源
|
||||
* @param int $categoryId
|
||||
* @param string $type
|
||||
* @param int $page
|
||||
* @return ProductListWithFilterInterface
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function categoryProduct(int $categoryId, $type = 'e-book', int $page = 1)
|
||||
{
|
||||
$pageSize = 10;
|
||||
$attribute = $this->filters[$type]['attribute'];
|
||||
$this->_categoryLayer = $this->layerResolver->get();
|
||||
$this->_categoryLayer->setCurrentCategory($categoryId);
|
||||
|
||||
$this->_categoryLayer->apply();
|
||||
$collection = $this->_categoryLayer->getProductCollection();
|
||||
|
||||
list($filters, $isMultiselect) = $this->getProductOptions($attribute, $this->filters[$type]['optionsLabel']);
|
||||
if ($this->restRequest->getParam($attribute)) {
|
||||
if ($isMultiselect) {
|
||||
$collection->addAttributeToFilter($attribute, ['finset' => explode(',', trim($this->restRequest->getParam($attribute)))]);
|
||||
} else {
|
||||
$collection->addAttributeToFilter($attribute, trim($this->restRequest->getParam($attribute)));
|
||||
}
|
||||
|
||||
}
|
||||
$collection->addAttributeToSelect('*')->setOrder('position', 'asc')
|
||||
->addAttributeToFilter('visibility', ['in' => [2,3,4]]);
|
||||
if ($type == 'product-information-sheets') {
|
||||
$collection->addAttributeToFilter('parent_skus', array('notnull' => true) )
|
||||
->addAttributeToFilter('parent_names', array('notnull' => true) )
|
||||
->addAttributeToFilter('resource_type', ['neq' => $this->getResourceTypeChinesePisOptionId()]);
|
||||
$keyword = $this->restRequest->getParam('keyword');
|
||||
if ($keyword) {
|
||||
$collection->addAttributeToFilter([
|
||||
['attribute' => 'parent_skus', 'like' => '%' . $keyword . '%'],
|
||||
['attribute' => 'parent_names', 'like' => '%' . $keyword . '%'],
|
||||
]);
|
||||
}
|
||||
$logger = ObjectManager::getInstance()->get(LoggerInterface::class);
|
||||
$logger->info($collection->getSelectSql(true));
|
||||
}
|
||||
|
||||
$collection->setPage($page, $pageSize);
|
||||
$this->setParent($collection);
|
||||
|
||||
return $this->productListWithFilter->setFilters(json_encode($filters))
|
||||
->setItems($collection->getItems())
|
||||
->setTotalCount($collection->getSize())
|
||||
->setFilterCode($attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实验方案
|
||||
* @return string
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function experimentalScheme()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/experimental-scheme.csv';
|
||||
$file = fopen($path, "r");
|
||||
$data = [];
|
||||
$mediaUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
|
||||
while (($row = fgetcsv($file)) !== FALSE) {
|
||||
if (isset($row[1])) {
|
||||
$row[0] = preg_replace('/^\xEF\xBB\xBF/', '', $row[0]);
|
||||
$data[$row[0]]['label'] = $row[0];
|
||||
$data[$row[0]]['list'][] = ['label' => $row[1], 'url' => $row[2], 'image'=>$mediaUrl.$row[3]];
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode(array_values($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Worksheet $sheet
|
||||
* @param string $cell
|
||||
* @return string
|
||||
*/
|
||||
protected function getCellValue(Worksheet $sheet, string $cell)
|
||||
{
|
||||
return trim((string)$sheet->getCell($cell)->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品手册接口
|
||||
* @return string
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function productManual()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/product-manual.xlsx';
|
||||
|
||||
$data = [];
|
||||
$sheet = Excel::getExcelSheet($path);
|
||||
$mediaUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
|
||||
foreach ($sheet->getRowIterator() as $row) {
|
||||
if ($row->getRowIndex() == 1) {
|
||||
continue;
|
||||
}
|
||||
$researchFiled = $this->getCellValue($sheet, 'A'.$row->getRowIndex());
|
||||
$name = $this->getCellValue($sheet, 'B'.$row->getRowIndex());
|
||||
$imagePath = $this->getCellValue($sheet, 'C'.$row->getRowIndex());
|
||||
$pdfPath = $this->getCellValue($sheet, 'D'.$row->getRowIndex());
|
||||
if (!empty($name)) {
|
||||
$data[$researchFiled]['label'] = $researchFiled;
|
||||
$data[$researchFiled]['list'][] = ['label' => $name, 'url' => $mediaUrl.$imagePath, 'pdf'=>$mediaUrl.$pdfPath];
|
||||
}
|
||||
}
|
||||
return json_encode(array_values($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作视频
|
||||
* @return string
|
||||
*/
|
||||
public function videos()
|
||||
{
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/operation-videos.xlsx';
|
||||
|
||||
$data = [];
|
||||
$sheet = Excel::getExcelSheet($path);
|
||||
|
||||
foreach ($sheet->getRowIterator() as $row) {
|
||||
if ($row->getRowIndex() == 1) {
|
||||
continue;
|
||||
}
|
||||
$categoryName = $this->getCellValue($sheet, 'A'.$row->getRowIndex());
|
||||
$categorySort = intval($this->getCellValue($sheet, 'B'.$row->getRowIndex()));
|
||||
// $duration = $this->getCellValue($sheet, 'C'.$row->getRowIndex());
|
||||
$duration = $sheet->getCell('C'.$row->getRowIndex())->getValue();
|
||||
|
||||
$videoTitle = $this->getCellValue($sheet, 'D'.$row->getRowIndex());
|
||||
$videoId = $this->getCellValue($sheet, 'E'.$row->getRowIndex());
|
||||
if (!empty($videoTitle)) {
|
||||
$data[$categoryName]['label'] = $categoryName;
|
||||
$data[$categoryName]['list'][] = ['name' => $videoTitle, 'duration' => $duration, 'video_id'=>$videoId];
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode(array_values($data));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Api;
|
||||
|
||||
use Magento\Framework\Webapi\Rest\Request as RestRequest;
|
||||
use Stemcell\Catalog\Model\ResourceModel\Cryopreserve\CollectionFactory as CryopreserveCollectionFactory;
|
||||
|
||||
/**
|
||||
* 样本冻存参考小工具接口
|
||||
*/
|
||||
class SampleCryopreserve
|
||||
{
|
||||
public function __construct(
|
||||
private CryopreserveCollectionFactory $cryopreserveCollectionFactory,
|
||||
private RestRequest $restRequest
|
||||
) {
|
||||
}
|
||||
|
||||
protected function getSamples() {
|
||||
$samples = [];
|
||||
$data = $this->cryopreserveCollectionFactory->create()->addFieldToSelect('sample')->load()->getData();
|
||||
foreach ($data as $item) {
|
||||
if (!isset($samples[$item['sample']])) {
|
||||
$samples[$item['sample']] = ['sample' => $item['sample']];
|
||||
}
|
||||
}
|
||||
return array_values($samples);
|
||||
}
|
||||
|
||||
protected function getTypes()
|
||||
{
|
||||
$sample = trim((string)$this->restRequest->getParam("sample"));
|
||||
$collection = $this->cryopreserveCollectionFactory->create();
|
||||
if (!empty($sample)) {
|
||||
$collection->addFieldToFilter('sample', $sample);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
foreach ($collection->getItems() as $item) {
|
||||
/* @var $item \Stemcell\Catalog\Model\Cryopreserve */
|
||||
if (!isset($data[$item->getType()])) {
|
||||
$data[$item->getType()] = ['type' => $item->getType()];
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($data);
|
||||
}
|
||||
|
||||
protected function getCellTypes()
|
||||
{
|
||||
$sample = trim((string)$this->restRequest->getParam("sample"));
|
||||
$type = trim((string)$this->restRequest->getParam("type"));
|
||||
$collection = $this->cryopreserveCollectionFactory->create();
|
||||
if (!empty($type)) {
|
||||
$collection->addFieldToFilter('sample', $sample)
|
||||
->addFieldToFilter('type', $type);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
foreach ($collection->getItems() as $item) {
|
||||
/* @var $item \Stemcell\Catalog\Model\Cryopreserve */
|
||||
if (!isset($data[$item->getCellType()])) {
|
||||
$data[$item->getCellType()] = ['cellType' => $item->getCellType()];
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return ['samples'=>$this->getSamples(), 'types'=>$this->getTypes(), 'cellTypes'=>$this->getCellTypes()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function execute() : string {
|
||||
$sample = trim((string)$this->restRequest->getParam("sample"));
|
||||
$type = trim((string)$this->restRequest->getParam("type"));
|
||||
$cellType = trim((string)$this->restRequest->getParam("cellType"));
|
||||
$collection = $this->cryopreserveCollectionFactory->create()
|
||||
->addFieldToSelect(['reference_density', 'desc', 'reference']);
|
||||
if (!empty($sample)) {
|
||||
$collection->addFieldToFilter('sample', $sample);
|
||||
}
|
||||
if (!empty($type)) {
|
||||
$collection->addFieldToFilter('type', $type);
|
||||
}
|
||||
if (!empty($cellType)) {
|
||||
$collection->addFieldToFilter('cell_type', $cellType);
|
||||
}
|
||||
|
||||
return json_encode(['filters' => $this->getFilters(), 'items' => $collection->getData()]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Api;
|
||||
|
||||
use Magento\Framework\Module\Dir;
|
||||
use Magento\Framework\Webapi\Rest\Request;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use Magento\Framework\App\CacheInterface;
|
||||
use Magento\Catalog\Helper\Image as ImageHelper;
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
|
||||
use Magento\Cms\Model\Template\FilterProvider;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
|
||||
/**
|
||||
* 小程序实用工具 - 多能干细胞维持培养工具
|
||||
*/
|
||||
class TesrProductFinder
|
||||
{
|
||||
protected array $filtersField = ['first', 'second', 'third', 'fourth'];
|
||||
const CACHE_IDENTIFIER = 'tesr_product_finder_cache';
|
||||
const IMAGE_PATH = 'catalog/product/cache/43f2e544b18f2e737c50422db3f53cf3/E/B/EB00005_8406f0a7325bcb2e1140145e13eef3cd_1_1.jpg';
|
||||
|
||||
const XML_PATH_WECHAT_TESR_PRODUCT_FINDER = 'commerce/wechat/tesr-product-finder';
|
||||
|
||||
public function __construct(
|
||||
protected Dir $dir,
|
||||
protected Request $restRequest,
|
||||
protected CacheInterface $cache,
|
||||
protected ImageHelper $imageHelper,
|
||||
protected ProductRepositoryInterface $productRepository,
|
||||
protected Product $product,
|
||||
protected ProductCollectionFactory $productCollectionFactory,
|
||||
protected ScopeConfigInterface $scopeConfig,
|
||||
protected FilterProvider $filterProvider,
|
||||
) {
|
||||
}
|
||||
|
||||
// 保存数据到缓存
|
||||
protected function saveToCache($data, $identifier, $tags = [], $lifeTime = null)
|
||||
{
|
||||
$tags = array_merge(['CUSTOM_TAG'], $tags);
|
||||
$lifeTime = $lifeTime ?: 3600; // 默认1小时
|
||||
|
||||
$this->cache->save(
|
||||
serialize($data),
|
||||
$identifier,
|
||||
$tags,
|
||||
$lifeTime
|
||||
);
|
||||
}
|
||||
|
||||
// 从缓存加载数据
|
||||
protected function loadFromCache($identifier)
|
||||
{
|
||||
$data = $this->cache->load($identifier);
|
||||
return $data ? unserialize($data) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getExcelData()
|
||||
{
|
||||
$data = $this->loadFromCache(self::CACHE_IDENTIFIER);
|
||||
if ($data !== false) {
|
||||
return $data;
|
||||
}
|
||||
$path = $this->dir->getDir('Stemcell_Catalog').'/data/tesr-product-finder.xlsx';
|
||||
$spreadsheet = IOFactory::load($path);
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// 获取所有数据
|
||||
$data = $worksheet->toArray();
|
||||
|
||||
// 第一行作为键名
|
||||
$headers = array_shift($data);
|
||||
|
||||
// 转换为关联数组
|
||||
$result = [];
|
||||
foreach ($data as $row) {
|
||||
$assocRow = [];
|
||||
foreach ($headers as $index => $header) {
|
||||
if ($header) {
|
||||
$assocRow[$header] = $row[$index] ?? null;
|
||||
if ($header=='skus') {
|
||||
$skus = array_map('trim', explode(',', $assocRow[$header]));
|
||||
$assocRow[$header] = $this->getProductsFromSku($skus);
|
||||
}
|
||||
}
|
||||
}
|
||||
$result[] = $assocRow;
|
||||
}
|
||||
$this->saveToCache($result, self::CACHE_IDENTIFIER);
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getProductsFromSku(array $skus)
|
||||
{
|
||||
$productCollection = $this->productCollectionFactory->create()
|
||||
->addAttributeToFilter('sku', ['in' => $skus])
|
||||
->addAttributeToSelect(['small_image', 'name']);
|
||||
|
||||
$data = [];
|
||||
foreach ($productCollection as $product) {
|
||||
$data[] = ['sku' => $product->getSku(), 'name' => $product->getName(), 'image' => $this->getImageUrl($product)];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getImageUrl(Product $product): string
|
||||
{
|
||||
return $this->imageHelper
|
||||
->init($product, 'category_page_list')
|
||||
->setImageFile($product->getSmallImage())
|
||||
->getUrl();
|
||||
}
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array[]
|
||||
*/
|
||||
protected function getFilters(array $data) {
|
||||
$filters = [];
|
||||
foreach ($this->filtersField as $field) {
|
||||
$filters[$field] = [];
|
||||
}
|
||||
foreach ($data as $row) {
|
||||
foreach ($this->filtersField as $field) {
|
||||
!in_array($row[$field], $filters[$field]) && $filters[$field][] = $row[$field];
|
||||
}
|
||||
}
|
||||
return $filters;
|
||||
}
|
||||
|
||||
protected function getBanners()
|
||||
{
|
||||
$config = $this->scopeConfig->getValue(
|
||||
self::XML_PATH_WECHAT_TESR_PRODUCT_FINDER,
|
||||
ScopeInterface::SCOPE_STORE
|
||||
);
|
||||
|
||||
if (!$config) {
|
||||
$config = [];
|
||||
} else {
|
||||
try {
|
||||
$config = $this->filterProvider->getPageFilter()->filter($config);
|
||||
$config = json_decode($config, true);
|
||||
} catch (\Exception $e) {
|
||||
$config = [];
|
||||
}
|
||||
|
||||
}
|
||||
$config = is_array($config) ? $config : [];
|
||||
return $config['banners'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$data = $this->getExcelData();
|
||||
$result = [];
|
||||
$criteria = $this->restRequest->getParams();
|
||||
foreach ($criteria as $key => $value) {
|
||||
$criteria[$key] = trim($value);
|
||||
}
|
||||
|
||||
$isFilterComplete = true;
|
||||
foreach ($this->filtersField as $field) {
|
||||
|
||||
if (empty($criteria[$field])) {
|
||||
$isFilterComplete = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($isFilterComplete) {
|
||||
foreach ($data as $row) {
|
||||
$notThisRow = false;
|
||||
foreach ($this->filtersField as $field) {
|
||||
if ($row[$field] != $criteria[$field]) {
|
||||
$notThisRow = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($notThisRow) {
|
||||
continue;
|
||||
} else {
|
||||
$result = $row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$product = $this->productRepository->get('EB00005');
|
||||
return json_encode([
|
||||
'filters' => $this->getFilters($data),
|
||||
'result' => $result,
|
||||
'resources' => [
|
||||
[
|
||||
'id'=>2,
|
||||
'name'=>'诱导多能干细胞:标准化且易获取的究模型',
|
||||
'image_url' => $this->getImageUrl($product),
|
||||
],
|
||||
],
|
||||
'banners' => $this->getBanners(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Stemcell\Catalog\Api\Data\CellSortInterface;
|
||||
|
||||
class CellSort extends AbstractModel implements CellSortInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
$this->_init(\Stemcell\Catalog\Model\ResourceModel\CellSort::class);
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCellSortId()
|
||||
{
|
||||
return $this->getData(self::CELLSORT_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSpeciesName()
|
||||
{
|
||||
return $this->getData(self::SPECIES_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSpeciesName(string $speciesName)
|
||||
{
|
||||
return $this->setData(self::SPECIES_NAME, $speciesName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTissueId()
|
||||
{
|
||||
return $this->getData(self::TISSUE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setTissueId(int $tissueId)
|
||||
{
|
||||
return $this->setData(self::TISSUE_ID, $tissueId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTissueName()
|
||||
{
|
||||
return $this->getData(self::TISSUE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setTissueName(string $tissueName)
|
||||
{
|
||||
return $this->setData(self::TISSUE_NAME, $tissueName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCellTypeId()
|
||||
{
|
||||
return $this->getData(self::CELL_TYPE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCellTypeId(int $cellTypeId)
|
||||
{
|
||||
return $this->setData(self::CELL_TYPE_ID, $cellTypeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCellTypeName()
|
||||
{
|
||||
return $this->getData(self::CELL_TYPE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCellTypeName(string $cellTypeName)
|
||||
{
|
||||
return $this->setData(self::CELL_TYPE_NAME, $cellTypeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFlag()
|
||||
{
|
||||
return $this->getData(self::FLAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setFlag($flag)
|
||||
{
|
||||
return $this->setData(self::FLAG, $flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSku()
|
||||
{
|
||||
return $this->getData(self::SKU);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSku(string $sku)
|
||||
{
|
||||
return $this->setData(self::FLAG, $sku);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSpeciesId()
|
||||
{
|
||||
return $this->getData(self::SPECIES_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSpeciesId(int $speciesId)
|
||||
{
|
||||
return $this->setData(self::SPECIES_ID, $speciesId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCellSubTypeId()
|
||||
{
|
||||
return $this->getData(self::CELL_SUBTYPE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCellSubTypeId(int $cellSubTypeId)
|
||||
{
|
||||
return $this->setData(self::CELL_SUBTYPE_ID, $cellSubTypeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCellSubTypeName()
|
||||
{
|
||||
return $this->getData(self::CELL_SUBTYPE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCellSubTypeName(string $cellSubTypeName)
|
||||
{
|
||||
return $this->setData(self::CELL_SUBTYPE_NAME, $cellSubTypeName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
|
||||
use Magento\Framework\Exception\CouldNotDeleteException;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Stemcell\Catalog\Api\CellSortRepositoryInterface;
|
||||
use Stemcell\Catalog\Api\Data\CellSortInterface;
|
||||
use Stemcell\Catalog\Api\Data\CellSortInterfaceFactory;
|
||||
use Stemcell\Catalog\Api\Data\CellSortSearchResultsInterfaceFactory;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellSort as ResourceCellSort;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellSort\CollectionFactory as CellSortCollectionFactory;
|
||||
|
||||
class CellSortRepository implements CellSortRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CellSortInterfaceFactory
|
||||
*/
|
||||
protected $cellSortFactory;
|
||||
|
||||
/**
|
||||
* @var CollectionProcessorInterface
|
||||
*/
|
||||
protected $collectionProcessor;
|
||||
|
||||
/**
|
||||
* @var ResourceCellSort
|
||||
*/
|
||||
protected $resource;
|
||||
|
||||
/**
|
||||
* @var CellSortCollectionFactory
|
||||
*/
|
||||
protected $cellSortCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var CellSort
|
||||
*/
|
||||
protected $searchResultsFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @param ResourceCellSort $resource
|
||||
* @param CellSortInterfaceFactory $cellSortFactory
|
||||
* @param CellSortCollectionFactory $cellSortCollectionFactory
|
||||
* @param CellSortSearchResultsInterfaceFactory $searchResultsFactory
|
||||
* @param CollectionProcessorInterface $collectionProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
ResourceCellSort $resource,
|
||||
CellSortInterfaceFactory $cellSortFactory,
|
||||
CellSortCollectionFactory $cellSortCollectionFactory,
|
||||
CellSortSearchResultsInterfaceFactory $searchResultsFactory,
|
||||
CollectionProcessorInterface $collectionProcessor
|
||||
) {
|
||||
$this->resource = $resource;
|
||||
$this->cellSortFactory = $cellSortFactory;
|
||||
$this->cellSortCollectionFactory = $cellSortCollectionFactory;
|
||||
$this->searchResultsFactory = $searchResultsFactory;
|
||||
$this->collectionProcessor = $collectionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function save(CellSortInterface $cellSort)
|
||||
{
|
||||
try {
|
||||
$this->resource->save($cellSort);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotSaveException(__(
|
||||
'Could not save the cellSort: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return $cellSort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get($cellSortId)
|
||||
{
|
||||
$cellSort = $this->cellSortFactory->create();
|
||||
$this->resource->load($cellSort, $cellSortId);
|
||||
if (!$cellSort->getId()) {
|
||||
throw new NoSuchEntityException(__('CellSort with id "%1" does not exist.', $cellSortId));
|
||||
}
|
||||
return $cellSort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $criteria
|
||||
) {
|
||||
$collection = $this->cellSortCollectionFactory->create();
|
||||
|
||||
$this->collectionProcessor->process($criteria, $collection);
|
||||
|
||||
$searchResults = $this->searchResultsFactory->create();
|
||||
$searchResults->setSearchCriteria($criteria);
|
||||
|
||||
$items = [];
|
||||
foreach ($collection as $model) {
|
||||
$items[] = $model;
|
||||
}
|
||||
|
||||
$searchResults->setItems($items);
|
||||
$searchResults->setTotalCount($collection->getSize());
|
||||
return $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function delete(CellSortInterface $cellSort)
|
||||
{
|
||||
try {
|
||||
$cellSortModel = $this->cellSortFactory->create();
|
||||
$this->resource->load($cellSortModel, $cellSort->getCellsortId());
|
||||
$this->resource->delete($cellSortModel);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotDeleteException(__(
|
||||
'Could not delete the CellSort: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteById($cellSortId)
|
||||
{
|
||||
return $this->delete($this->get($cellSortId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Stemcell\Catalog\Api\Data\CellSubTypeInterface;
|
||||
|
||||
class CellSubType extends AbstractModel implements CellSubTypeInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
$this->_init(\Stemcell\Catalog\Model\ResourceModel\CellSubType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCellsubtypeId()
|
||||
{
|
||||
return $this->getData(self::CELLSUBTYPE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCellsubtypeId($cellsubtypeId)
|
||||
{
|
||||
return $this->setData(self::CELLSUBTYPE_ID, $cellsubtypeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->getData(self::NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
return $this->setData(self::NAME, $name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
|
||||
use Magento\Framework\Exception\CouldNotDeleteException;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Stemcell\Catalog\Api\CellSubTypeRepositoryInterface;
|
||||
use Stemcell\Catalog\Api\Data\CellSubTypeInterface;
|
||||
use Stemcell\Catalog\Api\Data\CellSubTypeInterfaceFactory;
|
||||
use Stemcell\Catalog\Api\Data\CellSubTypeSearchResultsInterfaceFactory;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellSubType as ResourceCellSubType;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellSubType\CollectionFactory as CellSubTypeCollectionFactory;
|
||||
|
||||
class CellSubTypeRepository implements CellSubTypeRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ResourceCellSubType
|
||||
*/
|
||||
protected $resource;
|
||||
|
||||
/**
|
||||
* @var CellSubTypeInterfaceFactory
|
||||
*/
|
||||
protected $cellSubTypeFactory;
|
||||
|
||||
/**
|
||||
* @var CellSubTypeCollectionFactory
|
||||
*/
|
||||
protected $cellSubTypeCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var CellSubType
|
||||
*/
|
||||
protected $searchResultsFactory;
|
||||
|
||||
/**
|
||||
* @var CollectionProcessorInterface
|
||||
*/
|
||||
protected $collectionProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* @param ResourceCellSubType $resource
|
||||
* @param CellSubTypeInterfaceFactory $cellSubTypeFactory
|
||||
* @param CellSubTypeCollectionFactory $cellSubTypeCollectionFactory
|
||||
* @param CellSubTypeSearchResultsInterfaceFactory $searchResultsFactory
|
||||
* @param CollectionProcessorInterface $collectionProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
ResourceCellSubType $resource,
|
||||
CellSubTypeInterfaceFactory $cellSubTypeFactory,
|
||||
CellSubTypeCollectionFactory $cellSubTypeCollectionFactory,
|
||||
CellSubTypeSearchResultsInterfaceFactory $searchResultsFactory,
|
||||
CollectionProcessorInterface $collectionProcessor
|
||||
) {
|
||||
$this->resource = $resource;
|
||||
$this->cellSubTypeFactory = $cellSubTypeFactory;
|
||||
$this->cellSubTypeCollectionFactory = $cellSubTypeCollectionFactory;
|
||||
$this->searchResultsFactory = $searchResultsFactory;
|
||||
$this->collectionProcessor = $collectionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function save(CellSubTypeInterface $cellSubType)
|
||||
{
|
||||
try {
|
||||
$this->resource->save($cellSubType);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotSaveException(__(
|
||||
'Could not save the cellSubType: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return $cellSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get($cellSubTypeId)
|
||||
{
|
||||
$cellSubType = $this->cellSubTypeFactory->create();
|
||||
$this->resource->load($cellSubType, $cellSubTypeId);
|
||||
if (!$cellSubType->getId()) {
|
||||
throw new NoSuchEntityException(__('CellSubType with id "%1" does not exist.', $cellSubTypeId));
|
||||
}
|
||||
return $cellSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $criteria
|
||||
) {
|
||||
$collection = $this->cellSubTypeCollectionFactory->create();
|
||||
|
||||
$this->collectionProcessor->process($criteria, $collection);
|
||||
|
||||
$searchResults = $this->searchResultsFactory->create();
|
||||
$searchResults->setSearchCriteria($criteria);
|
||||
|
||||
$items = [];
|
||||
foreach ($collection as $model) {
|
||||
$items[] = $model;
|
||||
}
|
||||
|
||||
$searchResults->setItems($items);
|
||||
$searchResults->setTotalCount($collection->getSize());
|
||||
return $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function delete(CellSubTypeInterface $cellSubType)
|
||||
{
|
||||
try {
|
||||
$cellSubTypeModel = $this->cellSubTypeFactory->create();
|
||||
$this->resource->load($cellSubTypeModel, $cellSubType->getCellsubtypeId());
|
||||
$this->resource->delete($cellSubTypeModel);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotDeleteException(__(
|
||||
'Could not delete the CellSubType: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteById($cellSubTypeId)
|
||||
{
|
||||
return $this->delete($this->get($cellSubTypeId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Stemcell\Catalog\Api\Data\CellTypeInterface;
|
||||
|
||||
class CellType extends AbstractModel implements CellTypeInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
$this->_init(\Stemcell\Catalog\Model\ResourceModel\CellType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCelltypeId()
|
||||
{
|
||||
return $this->getData(self::CELL_TYPE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCellTypeName()
|
||||
{
|
||||
return $this->getData(self::CELL_TYPE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCellTypeName($cellTypeName)
|
||||
{
|
||||
return $this->setData(self::CELL_TYPE_NAME, $cellTypeName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
|
||||
use Magento\Framework\Exception\CouldNotDeleteException;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Stemcell\Catalog\Api\CellTypeRepositoryInterface;
|
||||
use Stemcell\Catalog\Api\Data\CellTypeInterface;
|
||||
use Stemcell\Catalog\Api\Data\CellTypeInterfaceFactory;
|
||||
use Stemcell\Catalog\Api\Data\CellTypeSearchResultsInterfaceFactory;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellType as ResourceCellType;
|
||||
use Stemcell\Catalog\Model\ResourceModel\CellType\CollectionFactory as CellTypeCollectionFactory;
|
||||
|
||||
class CellTypeRepository implements CellTypeRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ResourceCellType
|
||||
*/
|
||||
protected $resource;
|
||||
|
||||
/**
|
||||
* @var CellTypeInterfaceFactory
|
||||
*/
|
||||
protected $cellTypeFactory;
|
||||
|
||||
/**
|
||||
* @var CellTypeCollectionFactory
|
||||
*/
|
||||
protected $cellTypeCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var CellType
|
||||
*/
|
||||
protected $searchResultsFactory;
|
||||
|
||||
/**
|
||||
* @var CollectionProcessorInterface
|
||||
*/
|
||||
protected $collectionProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* @param ResourceCellType $resource
|
||||
* @param CellTypeInterfaceFactory $cellTypeFactory
|
||||
* @param CellTypeCollectionFactory $cellTypeCollectionFactory
|
||||
* @param CellTypeSearchResultsInterfaceFactory $searchResultsFactory
|
||||
* @param CollectionProcessorInterface $collectionProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
ResourceCellType $resource,
|
||||
CellTypeInterfaceFactory $cellTypeFactory,
|
||||
CellTypeCollectionFactory $cellTypeCollectionFactory,
|
||||
CellTypeSearchResultsInterfaceFactory $searchResultsFactory,
|
||||
CollectionProcessorInterface $collectionProcessor
|
||||
) {
|
||||
$this->resource = $resource;
|
||||
$this->cellTypeFactory = $cellTypeFactory;
|
||||
$this->cellTypeCollectionFactory = $cellTypeCollectionFactory;
|
||||
$this->searchResultsFactory = $searchResultsFactory;
|
||||
$this->collectionProcessor = $collectionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function save(CellTypeInterface $cellType)
|
||||
{
|
||||
try {
|
||||
$this->resource->save($cellType);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotSaveException(__(
|
||||
'Could not save the cellType: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return $cellType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get($cellTypeId)
|
||||
{
|
||||
$cellType = $this->cellTypeFactory->create();
|
||||
$this->resource->load($cellType, $cellTypeId);
|
||||
if (!$cellType->getId()) {
|
||||
throw new NoSuchEntityException(__('CellType with id "%1" does not exist.', $cellTypeId));
|
||||
}
|
||||
return $cellType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $criteria
|
||||
) {
|
||||
$collection = $this->cellTypeCollectionFactory->create();
|
||||
|
||||
$this->collectionProcessor->process($criteria, $collection);
|
||||
|
||||
$searchResults = $this->searchResultsFactory->create();
|
||||
$searchResults->setSearchCriteria($criteria);
|
||||
|
||||
$items = [];
|
||||
foreach ($collection as $model) {
|
||||
$items[] = $model;
|
||||
}
|
||||
|
||||
$searchResults->setItems($items);
|
||||
$searchResults->setTotalCount($collection->getSize());
|
||||
return $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function delete(CellTypeInterface $cellType)
|
||||
{
|
||||
try {
|
||||
$cellTypeModel = $this->cellTypeFactory->create();
|
||||
$this->resource->load($cellTypeModel, $cellType->getCelltypeId());
|
||||
$this->resource->delete($cellTypeModel);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotDeleteException(__(
|
||||
'Could not delete the CellType: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteById($cellTypeId)
|
||||
{
|
||||
return $this->delete($this->get($cellTypeId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Stemcell\Catalog\Api\Data\CryopreserveInterface;
|
||||
|
||||
class Cryopreserve extends AbstractModel implements CryopreserveInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
$this->_init(\Stemcell\Catalog\Model\ResourceModel\Cryopreserve::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCryopreserveId()
|
||||
{
|
||||
return $this->getData(self::CRYOPRESERVE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSample()
|
||||
{
|
||||
return $this->getData(self::SAMPLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSample($sample)
|
||||
{
|
||||
return $this->setData(self::SAMPLE, $sample);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->getData(self::TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
return $this->setData(self::TYPE, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCellType()
|
||||
{
|
||||
return $this->getData(self::CELL_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCellType($cellType)
|
||||
{
|
||||
return $this->setData(self::CELL_TYPE, $cellType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReferenceDensity()
|
||||
{
|
||||
return $this->getData(self::REFERENCE_DENSITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setReferenceDensity($referenceDensity)
|
||||
{
|
||||
return $this->setData(self::REFERENCE_DENSITY, $referenceDensity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDesc()
|
||||
{
|
||||
return $this->getData(self::DESC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setDesc($desc)
|
||||
{
|
||||
return $this->setData(self::DESC, $desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReference()
|
||||
{
|
||||
return $this->getData(self::REFERENCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setReference($reference)
|
||||
{
|
||||
return $this->setData(self::REFERENCE, $reference);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
|
||||
use Magento\Framework\Exception\CouldNotDeleteException;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Stemcell\Catalog\Api\CryopreserveRepositoryInterface;
|
||||
use Stemcell\Catalog\Api\Data\CryopreserveInterface;
|
||||
use Stemcell\Catalog\Api\Data\CryopreserveInterfaceFactory;
|
||||
use Stemcell\Catalog\Api\Data\CryopreserveSearchResultsInterfaceFactory;
|
||||
use Stemcell\Catalog\Model\ResourceModel\Cryopreserve as ResourceCryopreserve;
|
||||
use Stemcell\Catalog\Model\ResourceModel\Cryopreserve\CollectionFactory as CryopreserveCollectionFactory;
|
||||
|
||||
class CryopreserveRepository implements CryopreserveRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CryopreserveInterfaceFactory
|
||||
*/
|
||||
protected $cryopreserveFactory;
|
||||
|
||||
/**
|
||||
* @var Cryopreserve
|
||||
*/
|
||||
protected $searchResultsFactory;
|
||||
|
||||
/**
|
||||
* @var ResourceCryopreserve
|
||||
*/
|
||||
protected $resource;
|
||||
|
||||
/**
|
||||
* @var CollectionProcessorInterface
|
||||
*/
|
||||
protected $collectionProcessor;
|
||||
|
||||
/**
|
||||
* @var CryopreserveCollectionFactory
|
||||
*/
|
||||
protected $cryopreserveCollectionFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @param ResourceCryopreserve $resource
|
||||
* @param CryopreserveInterfaceFactory $cryopreserveFactory
|
||||
* @param CryopreserveCollectionFactory $cryopreserveCollectionFactory
|
||||
* @param CryopreserveSearchResultsInterfaceFactory $searchResultsFactory
|
||||
* @param CollectionProcessorInterface $collectionProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
ResourceCryopreserve $resource,
|
||||
CryopreserveInterfaceFactory $cryopreserveFactory,
|
||||
CryopreserveCollectionFactory $cryopreserveCollectionFactory,
|
||||
CryopreserveSearchResultsInterfaceFactory $searchResultsFactory,
|
||||
CollectionProcessorInterface $collectionProcessor
|
||||
) {
|
||||
$this->resource = $resource;
|
||||
$this->cryopreserveFactory = $cryopreserveFactory;
|
||||
$this->cryopreserveCollectionFactory = $cryopreserveCollectionFactory;
|
||||
$this->searchResultsFactory = $searchResultsFactory;
|
||||
$this->collectionProcessor = $collectionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function save(CryopreserveInterface $cryopreserve)
|
||||
{
|
||||
try {
|
||||
$this->resource->save($cryopreserve);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotSaveException(__(
|
||||
'Could not save the cryopreserve: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return $cryopreserve;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get($cryopreserveId)
|
||||
{
|
||||
$cryopreserve = $this->cryopreserveFactory->create();
|
||||
$this->resource->load($cryopreserve, $cryopreserveId);
|
||||
if (!$cryopreserve->getId()) {
|
||||
throw new NoSuchEntityException(__('cryopreserve with id "%1" does not exist.', $cryopreserveId));
|
||||
}
|
||||
return $cryopreserve;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $criteria
|
||||
) {
|
||||
$collection = $this->cryopreserveCollectionFactory->create();
|
||||
|
||||
$this->collectionProcessor->process($criteria, $collection);
|
||||
|
||||
$searchResults = $this->searchResultsFactory->create();
|
||||
$searchResults->setSearchCriteria($criteria);
|
||||
|
||||
$items = [];
|
||||
foreach ($collection as $model) {
|
||||
$items[] = $model;
|
||||
}
|
||||
|
||||
$searchResults->setItems($items);
|
||||
$searchResults->setTotalCount($collection->getSize());
|
||||
return $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function delete(CryopreserveInterface $cryopreserve)
|
||||
{
|
||||
try {
|
||||
$cryopreserveModel = $this->cryopreserveFactory->create();
|
||||
$this->resource->load($cryopreserveModel, $cryopreserve->getCryopreserveId());
|
||||
$this->resource->delete($cryopreserveModel);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotDeleteException(__(
|
||||
'Could not delete the cryopreserve: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteById($cryopreserveId)
|
||||
{
|
||||
return $this->delete($this->get($cryopreserveId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface;
|
||||
|
||||
class ExperimentalScheme extends AbstractModel implements ExperimentalSchemeInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
$this->_init(\Stemcell\Catalog\Model\ResourceModel\ExperimentalScheme::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getExperimentalschemeId()
|
||||
{
|
||||
return $this->getData(self::EXPERIMENTALSCHEME_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCollectionName()
|
||||
{
|
||||
return $this->getData(self::COLLECTION_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCollectionName(string $collectionName)
|
||||
{
|
||||
return $this->setData(self::COLLECTION_NAME, $collectionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->getData(self::TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setTitle(string $title)
|
||||
{
|
||||
return $this->setData(self::TITLE, $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getImage()
|
||||
{
|
||||
return $this->getData(self::IMAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setImage(string $image)
|
||||
{
|
||||
return $this->setData(self::IMAGE, $image);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getMpUrl()
|
||||
{
|
||||
return $this->getData(self::MP_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setMpUrl(string $mpUrl)
|
||||
{
|
||||
return $this->setData(self::MP_URL, $mpUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCollectionSort()
|
||||
{
|
||||
return $this->getData(self::COLLECTION_SORT);
|
||||
}
|
||||
|
||||
public function setCollectionSort(int $collectionSort)
|
||||
{
|
||||
return $this->setData(self::COLLECTION_SORT, $collectionSort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
|
||||
use Magento\Framework\Exception\CouldNotDeleteException;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Stemcell\Catalog\Api\Data\ExperimentalSchemeInterface;
|
||||
use Stemcell\Catalog\Api\Data\ExperimentalSchemeInterfaceFactory;
|
||||
use Stemcell\Catalog\Api\Data\ExperimentalSchemeSearchResultsInterfaceFactory;
|
||||
use Stemcell\Catalog\Api\ExperimentalSchemeRepositoryInterface;
|
||||
use Stemcell\Catalog\Model\ResourceModel\ExperimentalScheme as ResourceExperimentalScheme;
|
||||
use Stemcell\Catalog\Model\ResourceModel\ExperimentalScheme\CollectionFactory as ExperimentalSchemeCollectionFactory;
|
||||
|
||||
class ExperimentalSchemeRepository implements ExperimentalSchemeRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ResourceExperimentalScheme
|
||||
*/
|
||||
protected $resource;
|
||||
|
||||
/**
|
||||
* @var ExperimentalSchemeInterfaceFactory
|
||||
*/
|
||||
protected $experimentalSchemeFactory;
|
||||
|
||||
/**
|
||||
* @var ExperimentalSchemeCollectionFactory
|
||||
*/
|
||||
protected $experimentalSchemeCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var CollectionProcessorInterface
|
||||
*/
|
||||
protected $collectionProcessor;
|
||||
|
||||
/**
|
||||
* @var ExperimentalScheme
|
||||
*/
|
||||
protected $searchResultsFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @param ResourceExperimentalScheme $resource
|
||||
* @param ExperimentalSchemeInterfaceFactory $experimentalSchemeFactory
|
||||
* @param ExperimentalSchemeCollectionFactory $experimentalSchemeCollectionFactory
|
||||
* @param ExperimentalSchemeSearchResultsInterfaceFactory $searchResultsFactory
|
||||
* @param CollectionProcessorInterface $collectionProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
ResourceExperimentalScheme $resource,
|
||||
ExperimentalSchemeInterfaceFactory $experimentalSchemeFactory,
|
||||
ExperimentalSchemeCollectionFactory $experimentalSchemeCollectionFactory,
|
||||
ExperimentalSchemeSearchResultsInterfaceFactory $searchResultsFactory,
|
||||
CollectionProcessorInterface $collectionProcessor
|
||||
) {
|
||||
$this->resource = $resource;
|
||||
$this->experimentalSchemeFactory = $experimentalSchemeFactory;
|
||||
$this->experimentalSchemeCollectionFactory = $experimentalSchemeCollectionFactory;
|
||||
$this->searchResultsFactory = $searchResultsFactory;
|
||||
$this->collectionProcessor = $collectionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function save(
|
||||
ExperimentalSchemeInterface $experimentalScheme
|
||||
) {
|
||||
try {
|
||||
$this->resource->save($experimentalScheme);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotSaveException(__(
|
||||
'Could not save the experimentalScheme: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return $experimentalScheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get($experimentalSchemeId)
|
||||
{
|
||||
$experimentalScheme = $this->experimentalSchemeFactory->create();
|
||||
$this->resource->load($experimentalScheme, $experimentalSchemeId);
|
||||
if (!$experimentalScheme->getId()) {
|
||||
throw new NoSuchEntityException(__('ExperimentalScheme with id "%1" does not exist.', $experimentalSchemeId));
|
||||
}
|
||||
return $experimentalScheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $criteria
|
||||
) {
|
||||
$collection = $this->experimentalSchemeCollectionFactory->create();
|
||||
|
||||
$this->collectionProcessor->process($criteria, $collection);
|
||||
|
||||
$searchResults = $this->searchResultsFactory->create();
|
||||
$searchResults->setSearchCriteria($criteria);
|
||||
|
||||
$items = [];
|
||||
foreach ($collection as $model) {
|
||||
$items[] = $model;
|
||||
}
|
||||
|
||||
$searchResults->setItems($items);
|
||||
$searchResults->setTotalCount($collection->getSize());
|
||||
return $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function delete(
|
||||
ExperimentalSchemeInterface $experimentalScheme
|
||||
) {
|
||||
try {
|
||||
$experimentalSchemeModel = $this->experimentalSchemeFactory->create();
|
||||
$this->resource->load($experimentalSchemeModel, $experimentalScheme->getExperimentalschemeId());
|
||||
$this->resource->delete($experimentalSchemeModel);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotDeleteException(__(
|
||||
'Could not delete the ExperimentalScheme: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteById($experimentalSchemeId)
|
||||
{
|
||||
return $this->delete($this->get($experimentalSchemeId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Product\Gallery;
|
||||
|
||||
use Magento\Framework\Api\Data\ImageContentInterface;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
|
||||
/**
|
||||
* 重写\Magento\Catalog\Model\Product\Gallery\Processor的原因写在97行
|
||||
*/
|
||||
class Processor extends \Magento\Catalog\Model\Product\Gallery\Processor
|
||||
{
|
||||
protected \Magento\Framework\File\Mime $mime;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository,
|
||||
\Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDb,
|
||||
\Magento\Catalog\Model\Product\Media\Config $mediaConfig,
|
||||
\Magento\Framework\Filesystem $filesystem,
|
||||
\Magento\Catalog\Model\ResourceModel\Product\Gallery $resourceModel,
|
||||
\Magento\Framework\File\Mime $mime = null
|
||||
)
|
||||
{
|
||||
parent::__construct(
|
||||
$attributeRepository,
|
||||
$fileStorageDb,
|
||||
$mediaConfig,
|
||||
$filesystem,
|
||||
$resourceModel,
|
||||
$mime
|
||||
);
|
||||
$this->mime = $mime ?: ObjectManager::getInstance()->get(\Magento\Framework\File\Mime::class);
|
||||
}
|
||||
|
||||
public function addImage(
|
||||
\Magento\Catalog\Model\Product $product,
|
||||
$file,
|
||||
$mediaAttribute = null,
|
||||
$move = false,
|
||||
$exclude = true
|
||||
) {
|
||||
|
||||
$file = $this->mediaDirectory->getRelativePath($file);
|
||||
|
||||
if (!$this->mediaDirectory->isFile($file)) {
|
||||
throw new LocalizedException(__("The image $file doesn't exist."));
|
||||
}
|
||||
// if (PHP_SAPI === 'cli') {
|
||||
// echo 'Magento\Catalog\Model\Product\Gallery\Processor argument $file: ' .$file . PHP_EOL;
|
||||
// echo 'Magento\Catalog\Model\Product\Gallery\Processor $file = $this->mediaDirectory->getRelativePath($file): ' .$file . PHP_EOL;
|
||||
// }
|
||||
// phpcs:ignore Magento2.Functions.DiscouragedFunction
|
||||
$pathinfo = pathinfo($file);
|
||||
$imgExtensions = ['jpg', 'jpeg', 'gif', 'png'];
|
||||
if (!isset($pathinfo['extension']) || !in_array(strtolower($pathinfo['extension']), $imgExtensions)) {
|
||||
throw new LocalizedException(
|
||||
__('The image type for the file is invalid. Enter the correct image type and try again.')
|
||||
);
|
||||
}
|
||||
|
||||
$fileName = \Magento\MediaStorage\Model\File\Uploader::getCorrectFileName($pathinfo['basename']);
|
||||
$dispersionPath = \Magento\MediaStorage\Model\File\Uploader::getDispersionPath($fileName);
|
||||
$fileName = $dispersionPath . '/' . $fileName;
|
||||
|
||||
$fileName = $this->getNotDuplicatedFilename($fileName, $dispersionPath);
|
||||
|
||||
$destinationFile = $this->mediaConfig->getTmpMediaPath($fileName);
|
||||
|
||||
try {
|
||||
/** @var $storageHelper \Magento\MediaStorage\Helper\File\Storage\Database */
|
||||
$storageHelper = $this->fileStorageDb;
|
||||
if ($move) {
|
||||
$this->mediaDirectory->renameFile($file, $destinationFile);
|
||||
|
||||
//If this is used, filesystem should be configured properly
|
||||
$storageHelper->saveFile($this->mediaConfig->getTmpMediaShortUrl($fileName));
|
||||
} else {
|
||||
$this->mediaDirectory->copyFile($file, $destinationFile);
|
||||
|
||||
$storageHelper->saveFile($this->mediaConfig->getTmpMediaShortUrl($fileName));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new LocalizedException(__('The "%1" file couldn\'t be moved.', $e->getMessage()));
|
||||
}
|
||||
|
||||
$fileName = str_replace('\\', '/', $fileName);
|
||||
|
||||
$attrCode = $this->getAttribute()->getAttributeCode();
|
||||
$mediaGalleryData = $product->getData($attrCode);
|
||||
$position = 0;
|
||||
|
||||
$absoluteFilePath = $this->mediaDirectory->getAbsolutePath($destinationFile);
|
||||
$imageMimeType = $this->mime->getMimeType($absoluteFilePath);
|
||||
$imageContent = $this->mediaDirectory->readFile($absoluteFilePath);
|
||||
$imageBase64 = base64_encode($imageContent);
|
||||
/**
|
||||
* 这是Magento 2.4.7的原始代码,
|
||||
* 修改这个代码的原因是因为调用Magento\Catalog\Model\Product::addImageToMediaGallery()后,
|
||||
* 代码走到这里,filename不带extension(.jpg, .png),
|
||||
* 会导致\Magento\Framework\File\Uploader if (!$this->checkAllowedExtension($this->getFileExtension()))
|
||||
* 的$this->getFileExtension()拿到的是空
|
||||
*/
|
||||
$imageName = $pathinfo['filename'];
|
||||
if (empty(pathinfo($imageName, PATHINFO_EXTENSION))) {
|
||||
$imageName = $pathinfo['basename'];
|
||||
}
|
||||
|
||||
|
||||
if (!is_array($mediaGalleryData)) {
|
||||
$mediaGalleryData = ['images' => []];
|
||||
}
|
||||
|
||||
foreach ($mediaGalleryData['images'] as &$image) {
|
||||
if (isset($image['position']) && $image['position'] > $position) {
|
||||
$position = $image['position'];
|
||||
}
|
||||
}
|
||||
|
||||
$position++;
|
||||
$mediaGalleryData['images'][] = [
|
||||
'file' => $fileName,
|
||||
'position' => $position,
|
||||
'label' => '',
|
||||
'disabled' => (int)$exclude,
|
||||
'media_type' => 'image',
|
||||
'types' => $mediaAttribute,
|
||||
'content' => [
|
||||
'data' => [
|
||||
ImageContentInterface::NAME => $imageName,
|
||||
ImageContentInterface::BASE64_ENCODED_DATA => $imageBase64,
|
||||
ImageContentInterface::TYPE => $imageMimeType,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$product->setData($attrCode, $mediaGalleryData);
|
||||
|
||||
if ($mediaAttribute !== null) {
|
||||
$this->setMediaAttribute($product, $mediaAttribute, $fileName);
|
||||
}
|
||||
|
||||
return $fileName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Stemcell\Catalog\Api\Data\ProductManualSearchInterface;
|
||||
|
||||
class ProductManualSearch extends AbstractModel implements ProductManualSearchInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
$this->_init(\Stemcell\Catalog\Model\ResourceModel\ProductManualSearch::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSearchId()
|
||||
{
|
||||
return $this->getData(self::SEARCH_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSearchId($searchId)
|
||||
{
|
||||
return $this->setData(self::SEARCH_ID, $searchId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->getData(self::NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
return $this->setData(self::NAME, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSku()
|
||||
{
|
||||
return $this->getData(self::SKU);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSku($sku)
|
||||
{
|
||||
return $this->setData(self::SKU, $sku);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSearchSku()
|
||||
{
|
||||
return $this->getData(self::SEARCH_SKU);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSearchSku($searchSku)
|
||||
{
|
||||
return $this->setData(self::SEARCH_SKU, $searchSku);
|
||||
}
|
||||
|
||||
public function getSearchSkusByKeyword(string $keyword)
|
||||
{
|
||||
$keyword = trim($keyword);
|
||||
$sql = "SELECT DISTINCT search_sku
|
||||
FROM product_manual_search
|
||||
WHERE sku = '$keyword'
|
||||
OR MATCH(name) AGAINST('$keyword' IN BOOLEAN MODE)";
|
||||
|
||||
$result = $this->getResource()->getConnection()->fetchAll($sql);
|
||||
return array_column($result, 'search_sku');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model;
|
||||
|
||||
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
|
||||
use Magento\Framework\Exception\CouldNotDeleteException;
|
||||
use Magento\Framework\Exception\CouldNotSaveException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Stemcell\Catalog\Api\Data\ProductManualSearchInterface;
|
||||
use Stemcell\Catalog\Api\Data\ProductManualSearchInterfaceFactory;
|
||||
use Stemcell\Catalog\Api\Data\ProductManualSearchSearchResultsInterfaceFactory;
|
||||
use Stemcell\Catalog\Api\ProductManualSearchRepositoryInterface;
|
||||
use Stemcell\Catalog\Model\ResourceModel\ProductManualSearch as ResourceProductManualSearch;
|
||||
use Stemcell\Catalog\Model\ResourceModel\ProductManualSearch\CollectionFactory as ProductManualSearchCollectionFactory;
|
||||
|
||||
class ProductManualSearchRepository implements ProductManualSearchRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ProductManualSearchCollectionFactory
|
||||
*/
|
||||
protected $productManualSearchCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var ResourceProductManualSearch
|
||||
*/
|
||||
protected $resource;
|
||||
|
||||
/**
|
||||
* @var ProductManualSearchInterfaceFactory
|
||||
*/
|
||||
protected $productManualSearchFactory;
|
||||
|
||||
/**
|
||||
* @var CollectionProcessorInterface
|
||||
*/
|
||||
protected $collectionProcessor;
|
||||
|
||||
/**
|
||||
* @var ProductManualSearch
|
||||
*/
|
||||
protected $searchResultsFactory;
|
||||
|
||||
|
||||
/**
|
||||
* @param ResourceProductManualSearch $resource
|
||||
* @param ProductManualSearchInterfaceFactory $productManualSearchFactory
|
||||
* @param ProductManualSearchCollectionFactory $productManualSearchCollectionFactory
|
||||
* @param ProductManualSearchSearchResultsInterfaceFactory $searchResultsFactory
|
||||
* @param CollectionProcessorInterface $collectionProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
ResourceProductManualSearch $resource,
|
||||
ProductManualSearchInterfaceFactory $productManualSearchFactory,
|
||||
ProductManualSearchCollectionFactory $productManualSearchCollectionFactory,
|
||||
ProductManualSearchSearchResultsInterfaceFactory $searchResultsFactory,
|
||||
CollectionProcessorInterface $collectionProcessor
|
||||
) {
|
||||
$this->resource = $resource;
|
||||
$this->productManualSearchFactory = $productManualSearchFactory;
|
||||
$this->productManualSearchCollectionFactory = $productManualSearchCollectionFactory;
|
||||
$this->searchResultsFactory = $searchResultsFactory;
|
||||
$this->collectionProcessor = $collectionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function save(
|
||||
ProductManualSearchInterface $productManualSearch
|
||||
) {
|
||||
try {
|
||||
$this->resource->save($productManualSearch);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotSaveException(__(
|
||||
'Could not save the productManualSearch: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return $productManualSearch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function get($productManualSearchId)
|
||||
{
|
||||
$productManualSearch = $this->productManualSearchFactory->create();
|
||||
$this->resource->load($productManualSearch, $productManualSearchId);
|
||||
if (!$productManualSearch->getId()) {
|
||||
throw new NoSuchEntityException(__('ProductManualSearch with id "%1" does not exist.', $productManualSearchId));
|
||||
}
|
||||
return $productManualSearch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getList(
|
||||
\Magento\Framework\Api\SearchCriteriaInterface $criteria
|
||||
) {
|
||||
$collection = $this->productManualSearchCollectionFactory->create();
|
||||
|
||||
$this->collectionProcessor->process($criteria, $collection);
|
||||
|
||||
$searchResults = $this->searchResultsFactory->create();
|
||||
$searchResults->setSearchCriteria($criteria);
|
||||
|
||||
$items = [];
|
||||
foreach ($collection as $model) {
|
||||
$items[] = $model;
|
||||
}
|
||||
|
||||
$searchResults->setItems($items);
|
||||
$searchResults->setTotalCount($collection->getSize());
|
||||
return $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function delete(
|
||||
ProductManualSearchInterface $productManualSearch
|
||||
) {
|
||||
try {
|
||||
$productManualSearchModel = $this->productManualSearchFactory->create();
|
||||
$this->resource->load($productManualSearchModel, $productManualSearch->getProductmanualsearchId());
|
||||
$this->resource->delete($productManualSearchModel);
|
||||
} catch (\Exception $exception) {
|
||||
throw new CouldNotDeleteException(__(
|
||||
'Could not delete the ProductManualSearch: %1',
|
||||
$exception->getMessage()
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteById($productManualSearchId)
|
||||
{
|
||||
return $this->delete($this->get($productManualSearchId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class CellSort extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('cell_sort_product', 'cell_sort_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel\CellSort;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $_idFieldName = 'cellsort_id';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Stemcell\Catalog\Model\CellSort::class,
|
||||
\Stemcell\Catalog\Model\ResourceModel\CellSort::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class CellSubType extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('cell_sort_cell_subtype', 'cell_subtype_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel\CellSubType;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $_idFieldName = 'cell_subtype_id';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Stemcell\Catalog\Model\CellSubType::class,
|
||||
\Stemcell\Catalog\Model\ResourceModel\CellSubType::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class CellType extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('cell_sort_cell_type', 'cell_type_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel\CellType;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $_idFieldName = 'celltype_id';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Stemcell\Catalog\Model\CellType::class,
|
||||
\Stemcell\Catalog\Model\ResourceModel\CellType::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class Cryopreserve extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('cryopreserve', 'cryopreserve_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel\Cryopreserve;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $_idFieldName = 'cryopreserve_id';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Stemcell\Catalog\Model\Cryopreserve::class,
|
||||
\Stemcell\Catalog\Model\ResourceModel\Cryopreserve::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class ExperimentalScheme extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('experimental_scheme', 'experimental_scheme_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel\ExperimentalScheme;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $_idFieldName = 'experimental_scheme_id';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Stemcell\Catalog\Model\ExperimentalScheme::class,
|
||||
\Stemcell\Catalog\Model\ResourceModel\ExperimentalScheme::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class ProductManualSearch extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('product_manual_search', 'search_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel\ProductManualSearch;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $_idFieldName = 'search_id';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Stemcell\Catalog\Model\ProductManualSearch::class,
|
||||
\Stemcell\Catalog\Model\ResourceModel\ProductManualSearch::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class Species extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('cell_sort_species', 'species_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel\Species;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $_idFieldName = 'species_id';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Stemcell\Catalog\Model\Species::class,
|
||||
\Stemcell\Catalog\Model\ResourceModel\Species::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class Tissue extends AbstractDb
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init('cell_sort_tissue', 'tissue_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stemcell\Catalog\Model\ResourceModel\Tissue;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected $_idFieldName = 'tissue_id';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(
|
||||
\Stemcell\Catalog\Model\Tissue::class,
|
||||
\Stemcell\Catalog\Model\ResourceModel\Tissue::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Catalog\Model\Source;
|
||||
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class TaskStatus implements OptionSourceInterface
|
||||
{
|
||||
public function toOptionArray()
|
||||
{
|
||||
return [
|
||||
['value' => 'pending', 'label' => __('等待处理')],
|
||||
['value' => 'processing', 'label' => __('处理中')],
|
||||
['value' => 'success', 'label' => __('导入成功')],
|
||||
['value' => 'failed', 'label' => __('导入失败')],
|
||||
];
|
||||
}
|
||||
}
|
||||
{
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user