Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $model = Mage::getModel('task_creation/details');
- $collections = $model->getCollection();
- foreach($collections as $collection)
- {
- print_r($collection->getdata(''));
- }
- <?php
- namespace FMENewsModel;
- class News extends MagentoFrameworkModelAbstractModel implements NewsInterface, MagentoFrameworkDataObjectIdentityInterface
- {
- const CACHE_TAG = 'id';
- const ENABLED = 1;
- const DISABLED = 0;
- const COMPLETE = 0;
- const LEFT = 1;
- const RIGHT = 2;
- protected function _construct()
- {
- $this->_init('FMENewsModelResourceModelNews');
- }
- public function getIdentities()
- {
- return [self::CACHE_TAG . '_' . $this->getId()];
- }
- }
- <?php
- namespace FMENewsModel;
- interface NewsInterface
- {
- }
- <?php
- namespace FMENewsModelResourceModel;
- class News extends MagentoFrameworkModelResourceModelDbAbstractDb
- {
- protected function _construct()
- {
- $this->_init('fme_news','id');
- }
- <?php
- namespace FMENewsModelResourceModelNews;
- class Collection extends MagentoFrameworkModelResourceModelDbCollectionAbstractCollection
- {
- protected $_idFieldName = 'id';
- protected function _construct()
- {
- $this->_init('FMENewsModelNews','FMENewsModelResourceModelNews');
- }
- }
- protected $newscollectionFactory;
- public function __construct(....
- FMENewsModelResourceModelNewsCollectionFactory $newscollectionFactory
- ....)
- {
- ....
- $this->newscollectionFactory = $newscollectionFactory;
- .....
- }
- public function getNews()
- {
- $newsCollection = $this->newscollectionFactory->create();
- return $newsCollection;
- }
- $hostname = "yourhost";
- $username = "youruser";
- $password = "yourpwd";
- $database="yourdb";
- ini_set('display_errors', 1);
- $connection = mysqli_connect($hostname, $username, $password, $database);
- use MagentoStoreModelStore;
- use MagentoStoreModelStoreManager;
- require 'app/bootstrap.php';
- $opt['group'] = 'default';
- $opt['standaloneProcessStarted'] = '0';
- $params = $_SERVER;
- /* you can out your store id here */
- $params[StoreManager::PARAM_RUN_CODE] = 'admin';
- $params[Store::CUSTOM_ENTRY_POINT_PARAM] = true;
- /* create application */
- $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $params);
- /* the applocation
- /** @var MagentoFrameworkAppCron $app */
- $app = $bootstrap->createApplication('MagentoFrameworkAppCron', ['parameters' => $opt]);
- //$bootstrap->run($app);
- $objectManagerr = MagentoFrameworkAppObjectManager::getInstance();
- $appState = $objectManagerr->get("MagentoFrameworkAppState");
- $appState->setAreaCode("global");
- $categoryFactory = $objectManagerr->create('MagentoCatalogModelResourceModelCategoryCollectionFactory');
- $categoryy = $categoryFactory->create()
- ->addAttributeToSelect('*');
- $category = $objectManagerr->get('MagentoCatalogModelCategoryFactory')->create()->getCollection()
- ->addAttributeToFilter('url_key','werbeartikel-kategorien')
- ->addFieldToSelect('name')
- ->getFirstItem();
- private $_taskCollectionFactory;
- public function __construct(
- ...
- TaskCreationModelResourceModeldetailsCollectionFactory $collectionFactory,
- ...
- ) {
- $this->_taskCollectionFactory = $collectionFactory;
- ...
- }
- public function getTaskCollection(){
- $collection = $this->_taskCollectionFactory->create();
- $collection->addAttributeToSelect('*')
- return $collection;
- }
- <?php
- namespace InchooHelloworldControllerIndex;
- use MagentoFrameworkAppActionAction;
- use MagentoFrameworkAppActionContext;
- use InchooHelloworldModelPostFactory;
- class View extends Action
- {
- /**
- * @var TutorialSimpleNewsModelNewsFactory
- */
- protected $_modelPostFactory;
- /**
- * @param Context $context
- * @param NewsFactory $modelNewsFactory
- */
- public function __construct(
- Context $context,
- PostFactory $modelPostFactory
- ) {
- parent::__construct($context);
- $this->_modelPostFactory = $modelPostFactory;
- }
- public function execute()
- {
- /**
- * When Magento get your model, it will generate a Factory class
- * for your model at var/generaton folder and we can get your
- * model by this way
- */
- $postModel = $this->_modelPostFactory->create();
- // Load the item with ID is 1
- $item = $postModel->load(1);
- var_dump($item->getData());
- // Get news collection
- $postCollection = $postModel->getCollection();
- // Load all data of collection
- var_dump($postCollection->getData());
- }
- }
- $objectManager = MagentoFrameworkAppObjectManager::getInstance();
- $collection = $objectManager->get('VendorNameModuleNameModelClassName')
- ->getCollection()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement