Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 KB | None | 0 0
  1. $model = Mage::getModel('task_creation/details');
  2.  
  3. $collections = $model->getCollection();
  4.  
  5. foreach($collections as $collection)
  6. {
  7. print_r($collection->getdata(''));
  8. }
  9.  
  10. <?php
  11. namespace FMENewsModel;
  12.  
  13. class News extends MagentoFrameworkModelAbstractModel implements NewsInterface, MagentoFrameworkDataObjectIdentityInterface
  14. {
  15. const CACHE_TAG = 'id';
  16. const ENABLED = 1;
  17. const DISABLED = 0;
  18. const COMPLETE = 0;
  19. const LEFT = 1;
  20. const RIGHT = 2;
  21.  
  22.  
  23. protected function _construct()
  24. {
  25. $this->_init('FMENewsModelResourceModelNews');
  26. }
  27.  
  28. public function getIdentities()
  29. {
  30. return [self::CACHE_TAG . '_' . $this->getId()];
  31. }
  32.  
  33.  
  34.  
  35. }
  36.  
  37. <?php
  38. namespace FMENewsModel;
  39. interface NewsInterface
  40. {
  41.  
  42. }
  43.  
  44. <?php
  45. namespace FMENewsModelResourceModel;
  46.  
  47. class News extends MagentoFrameworkModelResourceModelDbAbstractDb
  48. {
  49. protected function _construct()
  50. {
  51. $this->_init('fme_news','id');
  52. }
  53.  
  54. <?php
  55. namespace FMENewsModelResourceModelNews;
  56. class Collection extends MagentoFrameworkModelResourceModelDbCollectionAbstractCollection
  57. {
  58. protected $_idFieldName = 'id';
  59. protected function _construct()
  60. {
  61. $this->_init('FMENewsModelNews','FMENewsModelResourceModelNews');
  62. }
  63. }
  64.  
  65. protected $newscollectionFactory;
  66. public function __construct(....
  67. FMENewsModelResourceModelNewsCollectionFactory $newscollectionFactory
  68. ....)
  69. {
  70. ....
  71. $this->newscollectionFactory = $newscollectionFactory;
  72. .....
  73. }
  74. public function getNews()
  75. {
  76.  
  77.  
  78. $newsCollection = $this->newscollectionFactory->create();
  79. return $newsCollection;
  80. }
  81.  
  82. $hostname = "yourhost";
  83. $username = "youruser";
  84. $password = "yourpwd";
  85. $database="yourdb";
  86. ini_set('display_errors', 1);
  87. $connection = mysqli_connect($hostname, $username, $password, $database);
  88. use MagentoStoreModelStore;
  89. use MagentoStoreModelStoreManager;
  90. require 'app/bootstrap.php';
  91. $opt['group'] = 'default';
  92. $opt['standaloneProcessStarted'] = '0';
  93. $params = $_SERVER;
  94. /* you can out your store id here */
  95. $params[StoreManager::PARAM_RUN_CODE] = 'admin';
  96. $params[Store::CUSTOM_ENTRY_POINT_PARAM] = true;
  97.  
  98. /* create application */
  99. $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $params);
  100. /* the applocation
  101. /** @var MagentoFrameworkAppCron $app */
  102.  
  103. $app = $bootstrap->createApplication('MagentoFrameworkAppCron', ['parameters' => $opt]);
  104. //$bootstrap->run($app);
  105.  
  106. $objectManagerr = MagentoFrameworkAppObjectManager::getInstance();
  107. $appState = $objectManagerr->get("MagentoFrameworkAppState");
  108. $appState->setAreaCode("global");
  109. $categoryFactory = $objectManagerr->create('MagentoCatalogModelResourceModelCategoryCollectionFactory');
  110. $categoryy = $categoryFactory->create()
  111. ->addAttributeToSelect('*');
  112. $category = $objectManagerr->get('MagentoCatalogModelCategoryFactory')->create()->getCollection()
  113. ->addAttributeToFilter('url_key','werbeartikel-kategorien')
  114. ->addFieldToSelect('name')
  115. ->getFirstItem();
  116.  
  117. private $_taskCollectionFactory;
  118.  
  119. public function __construct(
  120. ...
  121. TaskCreationModelResourceModeldetailsCollectionFactory $collectionFactory,
  122. ...
  123. ) {
  124. $this->_taskCollectionFactory = $collectionFactory;
  125. ...
  126. }
  127.  
  128. public function getTaskCollection(){
  129.  
  130. $collection = $this->_taskCollectionFactory->create();
  131. $collection->addAttributeToSelect('*')
  132.  
  133. return $collection;
  134. }
  135.  
  136. <?php
  137.  
  138. namespace InchooHelloworldControllerIndex;
  139.  
  140. use MagentoFrameworkAppActionAction;
  141. use MagentoFrameworkAppActionContext;
  142. use InchooHelloworldModelPostFactory;
  143.  
  144. class View extends Action
  145. {
  146. /**
  147. * @var TutorialSimpleNewsModelNewsFactory
  148. */
  149. protected $_modelPostFactory;
  150.  
  151. /**
  152. * @param Context $context
  153. * @param NewsFactory $modelNewsFactory
  154. */
  155. public function __construct(
  156. Context $context,
  157. PostFactory $modelPostFactory
  158. ) {
  159. parent::__construct($context);
  160. $this->_modelPostFactory = $modelPostFactory;
  161. }
  162.  
  163. public function execute()
  164. {
  165. /**
  166. * When Magento get your model, it will generate a Factory class
  167. * for your model at var/generaton folder and we can get your
  168. * model by this way
  169. */
  170. $postModel = $this->_modelPostFactory->create();
  171.  
  172. // Load the item with ID is 1
  173. $item = $postModel->load(1);
  174. var_dump($item->getData());
  175.  
  176. // Get news collection
  177. $postCollection = $postModel->getCollection();
  178. // Load all data of collection
  179. var_dump($postCollection->getData());
  180. }
  181. }
  182.  
  183. $objectManager = MagentoFrameworkAppObjectManager::getInstance();
  184.  
  185. $collection = $objectManager->get('VendorNameModuleNameModelClassName')
  186. ->getCollection()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement