Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $objectManager = MagentoFrameworkAppObjectManager::getInstance();
- $categories = [9];
- $productCollection = $objectManager->create('MagentoCatalogModelResourceModelProductCollectionFactory');
- $Category = $objectManager->create('MagentoCatalogModelCategory')->load($categories);
- $collection = $productCollection->create()->addAttributeToSelect('*')
- ->addAttributeToSort('price', 'DESC')
- ->joinField('category_id', 'catalog_category_product', 'category_id', 'product_id=entity_id', null, 'left') ->addFieldToFilter('category_id', ['in' => 9])->joinField(
- 'qty', 'cataloginventory_stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left'
- );
- foreach ($collection as $product){
- echo 'Name-->'.$product->getName().' Price--> '.$product->getPrice().'<br/>';
- //print_r($product->getData());
- }
Add Comment
Please, Sign In to add comment