从对象管理器子类id其中子类别在自定义类别创建了位于从根类别的产品收集

问题描述 投票:-1回答:1

我希望在类别ID的基础特定类别的所有产品。

我已经尝试下面的代码,但没有解决:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
$cateinstance = $objectManager->create('Magento\Catalog\Model\CategoryFactory');
$allcategoryproduct = $cateinstance->create()->load($cateid)->getProductCollection()->addAttributeToSelect('*');

[{"entity_id":"245","sku":"U001","type_id":"simple","category_id":null,"cat_index_position":"0","product_image":"\/p\/e\/peach-boy-boys-shirts_1_a8c05a1421e5dcf8ad5308398e0b3591_1.jpg","small_image":"\/p\/e\/peach-boy-boys-shirts_1_a8c05a1421e5dcf8ad5308398e0b3591_1.jpg","thumbnail":"\/p\/e\/peach-boy-boys-shirts_1_a8c05a1421e5dcf8ad5308398e0b3591_1.jpg","productName":"DY Andheri Peach School Uniform","price":"500.0000","isProductInStock":19,"isProductEndorsed":false,"option_collection":[]},{"entity_id":"250","sku":"U003","type_id":"configurable","category_id":null,"cat_index_position":"0","product_image":"\/0\/a\/0aea950b-1c0a-4adf-85ce-c521555462651534842479667-chalk-by-pantaloons-girls-dresses-4851534842479574-1.jpg","small_image":"\/0\/a\/0aea950b-1c0a-4adf-85ce-c521555462651534842479667-chalk-by-pantaloons-girls-dresses-4851534842479574-1.jpg","thumbnail":"\/0\/a\/0aea950b-1c0a-4adf-85ce-c521555462651534842479667-chalk-by-pantaloons-girls-dresses-4851534842479574-1.jpg","productName":"DY Andheri Girls School Uniform","price":"450.0000","isProductInStock":0,"isProductEndorsed":false,"option_collection":[{"sku":"DY Andheri Girls School Uniform-S","product_id":"250","attribute_id":"151","default_title":"Size","value_index":"30","display_label":"S","price":"450.0000"},{"sku":"DY Andheri Girls School Uniform-M","product_id":"250","attribute_id":"151","default_title":"Size","value_index":"31","display_label":"M","price":"450.0000"},{"sku":"DY Andheri Girls School Uniform-L","product_id":"250","attribute_id":"151","default_title":"Size","value_index":"32","display_label":"L","price":"450.0000"},{"sku":"DY Andheri Girls School Uniform-XL","product_id":"250","attribute_id":"151","default_title":"Size","value_index":"33","display_label":"XL","price":"450.0000"}]}]
magento-2.0
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.