本文整理汇总了PHP中Magento\Catalog\Model\Product\Type::getCompositeTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::getCompositeTypes方法的具体用法?PHP Type::getCompositeTypes怎么用?PHP Type::getCompositeTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Product\Type
的用法示例。
在下文中一共展示了Type::getCompositeTypes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadChildrens
/**
* Retrieve list of children ids for a product list.
*
* Warning the result use children ids as a key and list of parents as value
*
* @param array $productIds List of parent product ids.
*
* @return array
*/
public function loadChildrens($productIds)
{
$children = [];
foreach ($this->catalogProductType->getCompositeTypes() as $productTypeId) {
$typeInstance = $this->getProductTypeInstance($productTypeId);
$relation = $typeInstance->getRelationInfo();
if ($relation->getTable() && $relation->getParentFieldName() && $relation->getChildFieldName()) {
$relationTable = $this->getTable($relation->getTable());
$parentFieldName = $relation->getParentFieldName();
$childFieldName = $relation->getChildFieldName();
$select = $this->getConnection()->select()->from(['main' => $relationTable], [$parentFieldName, $childFieldName])->where("main.{$parentFieldName} in (?)", $productIds);
if ($relation->getWhere() !== null) {
$select->where($relation->getWhere());
}
$configurationTable = $this->getTable("catalog_product_super_attribute");
$configurableAttrExpr = "GROUP_CONCAT(DISTINCT super_table.attribute_id SEPARATOR ',')";
$select->joinLeft(["super_table" => $configurationTable], "super_table.product_id = main.{$parentFieldName}", ["configurable_attributes" => new \Zend_Db_Expr($configurableAttrExpr)]);
$select->group("main.{$childFieldName}");
$data = $this->getConnection()->fetchAll($select);
foreach ($data as $relationRow) {
$parentId = (int) $relationRow[$parentFieldName];
$childId = (int) $relationRow[$childFieldName];
$configurableAttributes = array_filter(explode(',', $relationRow["configurable_attributes"]));
$children[$childId][] = ["parent_id" => $parentId, "configurable_attributes" => $configurableAttributes];
}
}
}
return $children;
}
示例2: addOrderedQty
/**
* Add ordered qty's
*
* @param string $from
* @param string $to
* @return $this
*/
public function addOrderedQty($from = '', $to = '')
{
$adapter = $this->getConnection();
$compositeTypeIds = $this->_productType->getCompositeTypes();
$orderTableAliasName = $adapter->quoteIdentifier('order');
$orderJoinCondition = array($orderTableAliasName . '.entity_id = order_items.order_id', $adapter->quoteInto("{$orderTableAliasName}.state <> ?", \Magento\Sales\Model\Order::STATE_CANCELED));
$productJoinCondition = array($adapter->quoteInto('(e.type_id NOT IN (?))', $compositeTypeIds), 'e.entity_id = order_items.product_id', $adapter->quoteInto('e.entity_type_id = ?', $this->getProductEntityTypeId()));
if ($from != '' && $to != '') {
$fieldName = $orderTableAliasName . '.created_at';
$orderJoinCondition[] = $this->_prepareBetweenSql($fieldName, $from, $to);
}
$this->getSelect()->reset()->from(array('order_items' => $this->getTable('sales_flat_order_item')), array('ordered_qty' => 'SUM(order_items.qty_ordered)', 'order_items_name' => 'order_items.name'))->joinInner(array('order' => $this->getTable('sales_flat_order')), implode(' AND ', $orderJoinCondition), array())->joinLeft(array('e' => $this->getProductEntityTableName()), implode(' AND ', $productJoinCondition), array('entity_id' => 'order_items.product_id', 'entity_type_id' => 'e.entity_type_id', 'attribute_set_id' => 'e.attribute_set_id', 'type_id' => 'e.type_id', 'sku' => 'e.sku', 'has_options' => 'e.has_options', 'required_options' => 'e.required_options', 'created_at' => 'e.created_at', 'updated_at' => 'e.updated_at'))->where('parent_item_id IS NULL')->group('order_items.product_id')->having('SUM(order_items.qty_ordered) > ?', 0);
return $this;
}
示例3: testGetCompositeTypes
public function testGetCompositeTypes()
{
$types = $this->_productType->getCompositeTypes();
$this->assertInternalType('array', $types);
$this->assertContains(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE, $types);
}
示例4: getCompositeTypes
/**
* {@inheritdoc}
*/
public function getCompositeTypes()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getCompositeTypes');
if (!$pluginInfo) {
return parent::getCompositeTypes();
} else {
return $this->___callPlugins('getCompositeTypes', func_get_args(), $pluginInfo);
}
}