Guest User

Untitled

a guest
Nov 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. $objectManager = MagentoFrameworkAppObjectManager::getInstance();
  2. $categories = [9];
  3. $productCollection = $objectManager->create('MagentoCatalogModelResourceModelProductCollectionFactory');
  4. $Category = $objectManager->create('MagentoCatalogModelCategory')->load($categories);
  5. $collection = $productCollection->create()->addAttributeToSelect('*')
  6. ->addAttributeToSort('price', 'DESC')
  7. ->joinField('category_id', 'catalog_category_product', 'category_id', 'product_id=entity_id', null, 'left') ->addFieldToFilter('category_id', ['in' => 9])->joinField(
  8. 'qty', 'cataloginventory_stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left'
  9. );
  10.  
  11. foreach ($collection as $product){
  12. echo 'Name-->'.$product->getName().' Price--> '.$product->getPrice().'<br/>';
  13. //print_r($product->getData());
  14. }
Add Comment
Please, Sign In to add comment