13

Let us first see, what happens if you use the save() method directly on a product model like /** * @var Magento\Catalog\Model\Product $product */ $product->save(); The model class itself is Magento\Catalog\Model\Product Within this class, search for the definition of the save() method. None found right? Well, there's beforeSave() and afterSave(), ...


7

You will need to add sort order to search criteria Add \Magento\Framework\Api\SortOrderBuilder $sortOrderBuilder as dependency in constructor. public function getCollection() { $sortOrder = $this->sortOrderBuilder->setField('position')->setDirection('DESC')->create(); $searchCriteria = $this->searchCriteriaBuilder->...


4

Unfortunately, as of Magento 2.1-RC2 the Service Contracts method for store creation have not been implemented yet. I'm afraid you'll have to stick with the method you used for now as Magento core files uses the same method, see Magento/Backend/Controller/Adminhtml/System/Store/Save.php : $storeModel = $this->_objectManager->create('Magento\Store\...


2

You know all there is to know save(), get(), getList(), delete(), deleteById() Remember these are simply php classes and like any other can be customised to suit your needs But generally if you start with those you know that your code is consistent.


2

I understood we have to use repositories instead of collections not necessarily; AFAIK, when you use repositories you adhere to Magento 2 service contracts, which means that service interfaces and data interfaces are defined (but extensible by third-party modules). Making it possible at run-time to change the result of the call to the getList() method of ...


2

It is encouraged to use data interfaces (e.g. \Magento\Catalog\Api\Data\ProductInterface) instead of the model directly and use the repositories to load and save models. See Magento developer documentation


1

1) Make sure your auth.json is setup properly and has correct file permissions so the Magento can read the file. 2) Try copy the auth.json into the root Magento directory.


1

var_dump is not an good idea to check Object. That why you are getting hangup.You need to use X-debug for this


1

The repository classes should sit under Model IMHO. But I reckon it's more important to setup service contract classes for those repositories than placing them in the right folder because if you setup proper service contracts for those classes, their location does not really matter as you will be using the service contracts classes instead ;)


1

Thanks to @raphael-at-digital-pianism. I have the following code to create stores ("store views" as wrote in "adminhtml"): /** * Update/create store (frontname: "Store View"). * * @param int $storeId ID to update existing store or 'null' to create new one * @param string $name * @param string $code * @param int $websiteId * @param int $groupId (...


Only top voted, non community-wiki answers of a minimum length are eligible