dopo il debug molto su Magento2, ha rilevato che Magento2 non ha alcuna funzionalità per memorizzare i dati da API REST come p er StoreID getStore funzione in StoreManager basta controllare se il negozio è esiste in sessione predefinita altro ritorno, è per questo che tutti i REST chiamate API vengono memorizzati in archivio predefinito ID
Ho più di Rided Magento \ Conservare \ modello \ StoreManager come di seguito:
etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Store\Model\StoreManager" type="Emizentech\MobileAdmin\Model\EmizenStoreManager" />
</config>
vim Model/EmizenStoreManager.php
<?php
namespace Emizentech\MobileAdmin\Model;
use Magento\Store\Api\StoreResolverInterface;
use Magento\Framework\App\RequestInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class EmizenStoreManager extends \Magento\Store\Model\StoreManager
{
/**
* Request instance
*
* @var \Magento\Framework\App\RequestInterface
*/
protected $_request;
/**
* @param \Magento\Store\Api\StoreRepositoryInterface $storeRepository
* @param \Magento\Store\Api\GroupRepositoryInterface $groupRepository
* @param \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param StoreResolverInterface $storeResolver
* @param \Magento\Framework\Cache\FrontendInterface $cache
* @param bool $isSingleStoreAllowed
*/
public function __construct(
\Magento\Store\Api\StoreRepositoryInterface $storeRepository,
\Magento\Store\Api\GroupRepositoryInterface $groupRepository,
\Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
StoreResolverInterface $storeResolver,
\Magento\Framework\Cache\FrontendInterface $cache,
RequestInterface $request,
$isSingleStoreAllowed = true
) {
$this->storeRepository = $storeRepository;
$this->websiteRepository = $websiteRepository;
$this->groupRepository = $groupRepository;
$this->scopeConfig = $scopeConfig;
$this->storeResolver = $storeResolver;
$this->cache = $cache;
$this->_request = $request;
$this->isSingleStoreAllowed = $isSingleStoreAllowed;
}
/**
* {@inheritdoc}
*/
public function getStore($storeId = null)
{
if($this->_request->isPut() && strlen($this->_request->getParam('storeId')))
{
return parent::getStore($this->_request->getParam('storeId'));
}
return parent::getStore($storeId);
}
}
in questo file Ho controllo che, se richiesta tipo è PUT e URL paramater storeId esistono di Set che memorizzano altro chiamare parent :: getStore()
e in REST API PUT Chiama, ho aggiunto storeId in tutte le richieste in cui è necessario impostare le informazioni da memorizzare come per StoreID & funziona come un fascino :) per i valori di negozio in admin sto usando storeID = 0 ByDefault per tutte le richieste PUT.
fonte
2016-06-17 07:33:00
Grazie per questa risposta. C'è un problema (https://github.com/magento/magento2/issues/4952) segnalato per questo, ma questo sembra aiutare. Per migliorare la tua domanda: "tutti" equivale a store_id = 0 (admin), ma "default" può essere variabile. È vero, in una nuova installazione è di default, ma in multistore questo può essere 'en', 'de', 'fr', ecc. –