想要得到所有的UpSells产品,我不知道它是否有可能通过一个集合或一个searchCriteria。
发布于 2022-10-10 08:08:12
我找到了一种方法,这是一个定制的收藏:
private function _getUpSells()
{
// get only the enabled IDs
$productsIds = $this->_getAllEnabledIds();
// Magento\Catalog\Model\Product\Link as
$linkTypeUpSells = LinkModel::LINK_TYPE_UPSELL;
// construct: Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
$collection = $this->collectionFactory->create();
$collection->getSelect()
->join(
['CPL' => 'catalog_product_link'],
"CPL.linked_product_id = e.entity_id"
)->where(
'CPL.link_type_id = ?',
$linkTypeUpSells
)->where(
'CPL.product_id IN(?)',
$productsIds
)->group('e.entity_id');
return $collection;
}https://stackoverflow.com/questions/73473537
复制相似问题