本文整理汇总了PHP中Magento\Catalog\Model\ResourceModel\Product\Collection类的典型用法代码示例。如果您正苦于以下问题:PHP Collection类的具体用法?PHP Collection怎么用?PHP Collection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Collection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: install
/**
* {@inheritdoc}
*/
public function install(array $fixtures)
{
$this->configWriter->save('sales/msrp/enabled', 1);
foreach ($fixtures as $fileName) {
$fileName = $this->fixtureManager->getFixture($fileName);
if (!file_exists($fileName)) {
continue;
}
$rows = $this->csvReader->getData($fileName);
$header = array_shift($rows);
foreach ($rows as $row) {
$data = [];
foreach ($row as $key => $value) {
$data[$header[$key]] = $value;
}
$row = $data;
$productId = $this->getProductIdBySku($row['sku']);
if (!$productId) {
continue;
}
/** @var \Magento\Catalog\Model\Product $product */
$product = $this->productCollection->getItemById($productId);
$product->setMsrpDisplayActualPriceType(Type::TYPE_ON_GESTURE);
if (!empty($row['msrp'])) {
$price = $row['msrp'];
} else {
$price = $product->getPrice() * 1.1;
}
$product->setMsrp($price);
$product->save();
}
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:36,代码来源:Msrp.php
示例2: testGetCollection
public function testGetCollection()
{
$this->collectionMock->expects($this->once())->method('addAttributeToFilter');
$this->productLinkRepositoryMock->expects($this->once())->method('getList')->willReturn([]);
$this->requestMock->expects($this->exactly(2))->method('getParam')->willReturn(1);
$this->assertInstanceOf(Collection::class, $this->getModel()->getCollection());
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:7,代码来源:AbstractDataProviderTest.php
示例3: setUp
/**
* Set up
*/
protected function setUp()
{
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->rowCustomizerMock = $this->objectManagerHelper->getObject('\\Magento\\BundleImportExport\\Model\\Export\\RowCustomizer');
$this->productResourceCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', ['addAttributeToFilter', 'getIterator'], [], '', false);
$this->product = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getId', 'getPriceType', 'getSkuType', 'getPriceView', 'getWeightType', 'getTypeInstance', 'getOptionsCollection', 'getSelectionsCollection'], [], '', false);
$this->product->expects($this->any())->method('getId')->willReturn(1);
$this->product->expects($this->any())->method('getPriceType')->willReturn(1);
$this->product->expects($this->any())->method('getSkuType')->willReturn(1);
$this->product->expects($this->any())->method('getPriceView')->willReturn(1);
$this->product->expects($this->any())->method('getWeightType')->willReturn(1);
$this->product->expects($this->any())->method('getTypeInstance')->willReturnSelf();
$this->optionsCollection = $this->getMock('\\Magento\\Bundle\\Model\\ResourceModel\\Option\\Collection', ['setOrder', 'getIterator'], [], '', false);
$this->product->expects($this->any())->method('getOptionsCollection')->willReturn($this->optionsCollection);
$this->optionsCollection->expects($this->any())->method('setOrder')->willReturnSelf();
$this->option = $this->getMock('\\Magento\\Bundle\\Model\\Option', ['getId', 'getTitle', 'getType', 'getRequired'], [], '', false);
$this->option->expects($this->any())->method('getId')->willReturn(1);
$this->option->expects($this->any())->method('getTitle')->willReturn('title');
$this->option->expects($this->any())->method('getType')->willReturn(1);
$this->option->expects($this->any())->method('getRequired')->willReturn(1);
$this->optionsCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->option])));
$this->selection = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getSku', 'getSelectionPriceValue', 'getIsDefault', 'getSelectionQty', 'getSelectionPriceType'], [], '', false);
$this->selection->expects($this->any())->method('getSku')->willReturn(1);
$this->selection->expects($this->any())->method('getSelectionPriceValue')->willReturn(1);
$this->selection->expects($this->any())->method('getSelectionQty')->willReturn(1);
$this->selection->expects($this->any())->method('getSelectionPriceType')->willReturn(1);
$this->selectionsCollection = $this->getMock('\\Magento\\Bundle\\Model\\ResourceModel\\Selection\\Collection', ['getIterator', 'addAttributeToSort'], [], '', false);
$this->selectionsCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->selection])));
$this->selectionsCollection->expects($this->any())->method('addAttributeToSort')->willReturnSelf();
$this->product->expects($this->any())->method('getSelectionsCollection')->willReturn($this->selectionsCollection);
$this->productResourceCollection->expects($this->any())->method('addAttributeToFilter')->willReturnSelf();
$this->productResourceCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->product])));
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:36,代码来源:RowCustomizerTest.php
示例4: addExcludeProductFilter
/**
* Make collection not to load products that are in specified quote
*
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
* @param int $quoteId
* @return $this
*/
public function addExcludeProductFilter($collection, $quoteId)
{
$connection = $this->getConnection();
$exclusionSelect = $connection->select()->from($this->getTable('quote_item'), ['product_id'])->where('quote_id = ?', $quoteId);
$condition = $connection->prepareSqlCondition('e.entity_id', ['nin' => $exclusionSelect]);
$collection->getSelect()->where($condition);
return $this;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Cart.php
示例5: collectValidatedAttributes
/**
* Collect validated attributes for Product Collection
*
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection
* @return $this
*/
public function collectValidatedAttributes($productCollection)
{
$alias = array_keys($productCollection->getSelect()->getPart('from'))[0];
foreach ($this->getConditions() as $condition) {
$condition->setData('attribute', $alias . '.' . $condition->getData('attribute'));
$condition->addToCollection($productCollection);
}
return $this;
}
开发者ID:rafaelstz,项目名称:magento2,代码行数:15,代码来源:Combine.php
示例6: addFilterByAttributes
/**
* {@inheritDoc}
*/
protected function addFilterByAttributes(ProductCollection $productCollection, array $attributes)
{
foreach ($attributes as $code => $option) {
if (!is_array($option)) {
$option = [$option];
}
$productCollection->addAttributeToFilter($code, ['in' => $option]);
}
}
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:12,代码来源:Swatches.php
示例7: tearDown
/**
* Execute per test cleanup
*/
public function tearDown()
{
/** @var \Magento\Framework\Registry $registry */
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Registry');
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', true);
$this->productCollection->addFieldToFilter('entity_id', ['in' => [10, 11, 12]])->delete();
unset($this->productCollection);
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:14,代码来源:StockItemTest.php
示例8: aroundAddFilter
/**
* Replace WHERE-filtering by HAVING-filtering.
*
* @param \Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFilterToCollection $subject
* @param \Closure $proceed
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
* @param $field
* @param null $condition
*/
public function aroundAddFilter(\Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFilterToCollection $subject, \Closure $proceed, \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, $field, $condition = null)
{
/* skip identical conditions () */
$regKey = print_r($condition, true);
if (!isset($this->_regCond[$regKey])) {
$conn = $collection->getConnection();
$select = $collection->getSelect();
$equation = $this->_repoModifierProductGFrid->getEquationQty();
$prepared = $conn->prepareSqlCondition($equation, $condition);
$select->having($prepared);
$this->_regCond[$regKey] = true;
}
return;
}
开发者ID:praxigento,项目名称:mobi_mod_mage2_warehouse,代码行数:23,代码来源:AddQuantityFilterToCollection.php
示例9: afterAddStockDataToCollection
/**
* Replace default stock id in the where clause by stock id corresponded with store id.
*
* @param \Magento\CatalogInventory\Model\ResourceModel\Stock\Status $subject
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $result
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
*/
public function afterAddStockDataToCollection(\Magento\CatalogInventory\Model\ResourceModel\Stock\Status $subject, \Magento\Catalog\Model\ResourceModel\Product\Collection $result)
{
/** @var \Magento\Framework\Db\Select $select */
$select = $result->getSelect();
$from = $select->getPart('from');
$join = $from['stock_status_index'];
$cond = $join['joinCondition'];
$stockId = $this->_manStock->getCurrentStockId();
$fixed = str_replace('.stock_id = 1', '.stock_id = ' . $stockId, $cond);
$join['joinCondition'] = $fixed;
$from['stock_status_index'] = $join;
$select->setPart('from', $from);
return $result;
}
开发者ID:praxigento,项目名称:mobi_mod_mage2_warehouse,代码行数:21,代码来源:Status.php
示例10: _prepareData
/**
* @return $this
*/
protected function _prepareData()
{
$product = $this->_coreRegistry->registry('product');
/* @var $product \Magento\Catalog\Model\Product */
$this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect('required_options')->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout')) {
$this->_addProductAttributesAndPrices($this->_itemCollection);
}
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product) {
$product->setDoNotUseCategoryId(true);
}
return $this;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Related.php
示例11: testFindAttributeIdsByProductIds
public function testFindAttributeIdsByProductIds()
{
$productIds = [1, 2, 3];
$attributeSetIds = [3, 4, 6];
$select = $this->getMockBuilder(Select::class)->disableOriginalConstructor()->getMock();
$select->expects($this->once())->method('reset')->with(Select::COLUMNS)->willReturnSelf();
$select->expects($this->once())->method('columns')->with(ProductInterface::ATTRIBUTE_SET_ID)->willReturnSelf();
$select->expects($this->once())->method('where')->with('entity_id IN (?)', $productIds)->willReturnSelf();
$select->expects($this->once())->method('group')->with(ProductInterface::ATTRIBUTE_SET_ID)->willReturnSelf();
$connection = $this->getMock(AdapterInterface::class);
$connection->expects($this->once())->method('fetchCol')->with($select)->willReturn($attributeSetIds);
$this->productCollection->expects($this->once())->method('getSelect')->willReturn($select);
$this->productCollection->expects($this->once())->method('getConnection')->willReturn($connection);
$this->assertEquals($attributeSetIds, $this->attributeSetFinder->findAttributeSetIdsByProductIds($productIds));
}
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:AttributeSetFinderTest.php
示例12: _prepareCollection
/**
* Premare block data
* @return $this
*/
protected function _prepareCollection()
{
$post = $this->_coreRegistry->registry('current_blog_post');
$this->_itemCollection = $this->_productCollectionFactory->create()->addAttributeToSelect('required_options')->addStoreFilter()->addAttributeToFilter('entity_id', array('in' => $post->getRelatedProductIds() ?: array(0)));
if ($this->_moduleManager->isEnabled('Magento_Checkout')) {
$this->_addProductAttributesAndPrices($this->_itemCollection);
}
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->setPageSize((int) $this->_scopeConfig->getValue('mfblog/post_view/related_products/number_of_products', \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product) {
$product->setDoNotUseCategoryId(true);
}
return $this;
}
开发者ID:samitrimal,项目名称:Blog-Extension-for-Magento-2,代码行数:19,代码来源:RelatedProducts.php
示例13: _prepareCollection
/**
* Premare block data
* @return $this
*/
protected function _prepareCollection()
{
$post = $this->getPost();
$this->_itemCollection = $post->getRelatedProducts()->addAttributeToSelect('required_options');
if ($this->_moduleManager->isEnabled('Magento_Checkout')) {
$this->_addProductAttributesAndPrices($this->_itemCollection);
}
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->setPageSize((int) $this->_scopeConfig->getValue('mfblog/post_view/related_products/number_of_products', \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
$this->_itemCollection->getSelect()->order('rl.position', 'ASC');
$this->_itemCollection->load();
foreach ($this->_itemCollection as $product) {
$product->setDoNotUseCategoryId(true);
}
return $this;
}
开发者ID:magefan,项目名称:module-blog,代码行数:20,代码来源:RelatedProducts.php
示例14: addAttributeToSort
/**
* Add attribute to sort
*
* @param string $attribute
* @param string $dir
* @return $this|\Magento\Catalog\Model\ResourceModel\Product\Collection
*/
public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC)
{
if (in_array($attribute, ['review_cnt', 'last_created', 'avg_rating', 'avg_rating_approved'])) {
$this->getSelect()->order($attribute . ' ' . $dir);
return $this;
}
return parent::addAttributeToSort($attribute, $dir);
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:15,代码来源:Collection.php
示例15: addfilterByParent
protected function addfilterByParent()
{
$this->productCollectionMock->method('getTable')->with('catalog_product_relation')->willReturn('catalog_product_relation');
$zendDbSelectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
$this->productCollectionMock->method('getSelect')->willReturn($zendDbSelectMock);
$zendDbSelectMock->method('join')->willReturn($zendDbSelectMock);
$zendDbSelectMock->method('where')->willReturn($zendDbSelectMock);
}
开发者ID:vv-team,项目名称:foodo,代码行数:8,代码来源:DataTest.php
示例16: _prepareData
/**
* @return $this
*/
protected function _prepareData()
{
$product = $this->_coreRegistry->registry('product');
/* @var $product \Magento\Catalog\Model\Product */
$this->_itemCollection = $product->getUpSellProductCollection()->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout')) {
$this->_addProductAttributesAndPrices($this->_itemCollection);
}
$this->_itemCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$this->_itemCollection->load();
/**
* Updating collection with desired items
*/
$this->_eventManager->dispatch('catalog_product_upsell', ['product' => $product, 'collection' => $this->_itemCollection, 'limit' => null]);
foreach ($this->_itemCollection as $product) {
$product->setDoNotUseCategoryId(true);
}
return $this;
}
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:22,代码来源:Upsell.php
示例17: setUp
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function setUp()
{
parent::setUp();
$this->setCollectionFactory = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
$this->setCollection = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
$this->setCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
$item = new \Magento\Framework\DataObject(['id' => 1, 'attribute_set_name' => 'Default', '_attribute_set' => 'Default']);
$this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([$item]));
$this->attrCollectionFactory = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
$this->attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection', ['setAttributeSetFilter'], [], '', false);
$superAttributes = [];
foreach ($this->_getSuperAttributes() as $superAttribute) {
$item = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', ['isStatic'], $superAttribute, '', false);
$item->setData($superAttribute);
$item->method('isStatic')->will($this->returnValue(false));
$superAttributes[] = $item;
}
$this->attrCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->attrCollection));
$this->attrCollection->expects($this->any())->method('setAttributeSetFilter')->will($this->returnValue($superAttributes));
$this->_entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getNewSku', 'getOldSku', 'getNextBunch', 'isRowAllowedToImport', 'getConnection', 'getAttrSetIdToName', 'getErrorAggregator', 'getAttributeOptions'], [], '', false);
$this->_entityModel->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject());
$this->params = [0 => $this->_entityModel, 1 => 'configurable'];
$this->_connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto'], [], '', false);
$this->select = $this->getMock('Magento\\Framework\\DB\\Select', ['from', 'where', 'joinLeft', 'getConnection'], [], '', false);
$this->select->expects($this->any())->method('from')->will($this->returnSelf());
$this->select->expects($this->any())->method('where')->will($this->returnSelf());
$this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
$this->_connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
$connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
$connectionMock->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
$this->select->expects($this->any())->method('getConnection')->willReturn($connectionMock);
$this->_connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
$this->_connection->expects($this->any())->method('delete')->willReturnSelf();
$this->_connection->expects($this->any())->method('quoteInto')->willReturn('');
$this->_connection->expects($this->any())->method('fetchAll')->will($this->returnValue([]));
$this->resource = $this->getMock('\\Magento\\Framework\\App\\ResourceConnection', ['getConnection', 'getTableName'], [], '', false);
$this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->_connection));
$this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
$this->_entityModel->expects($this->any())->method('getConnection')->will($this->returnValue($this->_connection));
$this->productCollectionFactory = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\CollectionFactory', ['create'], [], '', false);
$this->productCollection = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', ['addFieldToFilter', 'addAttributeToSelect'], [], '', false);
$products = [];
$testProducts = [['id' => 1, 'attribute_set_id' => 4, 'testattr2' => 1, 'testattr3' => 1], ['id' => 2, 'attribute_set_id' => 4, 'testattr2' => 1, 'testattr3' => 1], ['id' => 20, 'attribute_set_id' => 4, 'testattr2' => 1, 'testattr3' => 1]];
foreach ($testProducts as $product) {
$item = $this->getMock('\\Magento\\Framework\\DataObject', ['getAttributeSetId'], [], '', false);
$item->setData($product);
$item->expects($this->any())->method('getAttributeSetId')->willReturn(4);
$products[] = $item;
}
$this->productCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->productCollection));
$this->productCollection->expects($this->any())->method('addFieldToFilter')->will($this->returnValue($this->productCollection));
$this->productCollection->expects($this->any())->method('addAttributeToSelect')->will($this->returnValue($products));
$this->_entityModel->expects($this->any())->method('getAttributeOptions')->will($this->returnValue(['attr2val1' => '1', 'attr2val2' => '2', 'attr2val3' => '3', 'testattr3v1' => '4', 'testattr30v1' => '4', 'testattr3v2' => '5', 'testattr3v3' => '6']));
$this->configurable = $this->objectManagerHelper->getObject('Magento\\ConfigurableImportExport\\Model\\Import\\Product\\Type\\Configurable', ['attrSetColFac' => $this->setCollectionFactory, 'prodAttrColFac' => $this->attrCollectionFactory, 'params' => $this->params, 'resource' => $this->resource, 'productColFac' => $this->productCollectionFactory]);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:58,代码来源:ConfigurableTest.php
示例18: getProductIdBySku
/**
* Retrieve product ID by sku
*
* @param string $sku
* @return int|null
*/
protected function getProductIdBySku($sku)
{
if (empty($this->productIds)) {
$this->productCollection->addAttributeToSelect('sku');
foreach ($this->productCollection as $product) {
$this->productIds[$product->getSku()] = $product->getId();
}
}
if (isset($this->productIds[$sku])) {
return $this->productIds[$sku];
}
return null;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:Converter.php
示例19: getItems
/**
* @return array|\Magento\Framework\Data\Collection\AbstractDb
*/
public function getItems()
{
$order = $this->getOrder();
if (!$order) {
return [];
}
$items = $order->getAllVisibleItems();
$productIds = [];
//get the product ids for the collection
foreach ($items as $item) {
$productIds[] = $item->getProductId();
}
$items = $this->productCollection->addAttributeToSelect('*')->addFieldToFilter('entity_id', ['in' => $productIds]);
return $items;
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:18,代码来源:Review.php
示例20: prepareData
/**
* Prepare configurable data for export
*
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
* @param int $productIds
* @return void
*/
public function prepareData($collection, $productIds)
{
$collection->addAttributeToFilter('entity_id', ['in' => $productIds])->addAttributeToFilter('type_id', ['eq' => \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE]);
while ($product = $collection->fetchItem()) {
$productAttributesOptions = $product->getTypeInstance()->getConfigurableOptions($product);
foreach ($productAttributesOptions as $productAttributeOption) {
$this->configurableData[$product->getId()] = [];
$variations = [];
$variationsLabels = [];
foreach ($productAttributeOption as $optValues) {
$variations[$optValues['sku']][] = $optValues['attribute_code'] . '=' . $optValues['option_title'];
if (!empty($optValues['super_attribute_label'])) {
$variationsLabels[$optValues['attribute_code']] = $optValues['attribute_code'] . '=' . $optValues['super_attribute_label'];
}
}
foreach ($variations as $sku => $values) {
$variations[$sku] = 'sku=' . $sku . ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR . implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $values);
}
$variations = implode(ImportProduct::PSEUDO_MULTI_LINE_SEPARATOR, $variations);
$variationsLabels = implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $variationsLabels);
$this->configurableData[$product->getId()] = ['configurable_variations' => $variations, 'configurable_variation_labels' => $variationsLabels];
}
}
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:31,代码来源:RowCustomizer.php
注:本文中的Magento\Catalog\Model\ResourceModel\Product\Collection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论