Created
          December 13, 2022 10:38 
        
      - 
      
 - 
        
Save magefast/6bbc7f7d18566cc1370e0ab3e9805f44 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
magefast created this gist
Dec 13, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); require_once __DIR__ . '/../app/bootstrap.php'; use Magento\Framework\App\Bootstrap; $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); $state = $objectManager->get('Magento\Framework\App\State'); $state->setAreaCode('adminhtml'); $collection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory'); $collection = $collection->create(); $collection->addAttributeToSelect('entity_id')->addAttributeToSelect(['sku', 'name']); $collection->addCategoriesFilter(['in' => [280]]); $collection->addAttributeToSelect('category_ids')->addCategoryIds(); $arrayMedia = []; foreach ($collection as $product) { if ($product->getStatus() == 1) { var_dump($product->getCategoryIds()); var_dump($product->getName()); var_dump($product->getSku()); } } unset($collection); die('--------');