当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestInterface::getPost方法代码示例

本文整理汇总了PHP中Magento\Framework\App\RequestInterface::getPost方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getPost方法的具体用法?PHP RequestInterface::getPost怎么用?PHP RequestInterface::getPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\App\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::getPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: afterInitialize

 /**
  * Prepare product to save
  *
  * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject
  * @param \Magento\Catalog\Model\Product $product
  *
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterInitialize(\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, \Magento\Catalog\Model\Product $product)
 {
     if ($downloadable = $this->request->getPost('downloadable')) {
         $product->setDownloadableData($downloadable);
     }
     return $product;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Downloadable.php

示例2: afterInitialize

 /**
  * Setting Bundle Items Data to product for further processing
  *
  * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject
  * @param \Magento\Catalog\Model\Product $product
  *
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function afterInitialize(\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, \Magento\Catalog\Model\Product $product)
 {
     $compositeReadonly = $product->getCompositeReadonly();
     $result['bundle_selections'] = $result['bundle_options'] = [];
     if (isset($this->request->getPost('bundle_options')['bundle_options'])) {
         foreach ($this->request->getPost('bundle_options')['bundle_options'] as $key => $option) {
             if (empty($option['bundle_selections'])) {
                 continue;
             }
             $result['bundle_selections'][$key] = $option['bundle_selections'];
             unset($option['bundle_selections']);
             $result['bundle_options'][$key] = $option;
         }
         if ($result['bundle_selections'] && !$compositeReadonly) {
             $product->setBundleSelectionsData($result['bundle_selections']);
         }
         if ($result['bundle_options'] && !$compositeReadonly) {
             $product->setBundleOptionsData($result['bundle_options']);
         }
         $this->processBundleOptionsData($product);
         $this->processDynamicOptionsData($product);
     }
     $affectProductSelections = (bool) $this->request->getPost('affect_bundle_product_selections');
     $product->setCanSaveBundleSelections($affectProductSelections && !$compositeReadonly);
     return $product;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:37,代码来源:Bundle.php

示例3: initialize

 /**
  * Initialize product before saving
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return \Magento\Catalog\Model\Product
  */
 public function initialize(\Magento\Catalog\Model\Product $product)
 {
     $productData = $this->request->getPost('product');
     if ($productData) {
         $stockData = isset($productData['stock_data']) ? $productData['stock_data'] : array();
         $productData['stock_data'] = $this->stockFilter->filter($stockData);
     }
     foreach (array('category_ids', 'website_ids') as $field) {
         if (!isset($productData[$field])) {
             $productData[$field] = array();
         }
     }
     $wasLockedMedia = false;
     if ($product->isLockedAttribute('media')) {
         $product->unlockAttribute('media');
         $wasLockedMedia = true;
     }
     $product->addData($productData);
     if ($wasLockedMedia) {
         $product->lockAttribute('media');
     }
     if ($this->storeManager->hasSingleStore()) {
         $product->setWebsiteIds(array($this->storeManager->getStore(true)->getWebsite()->getId()));
     }
     /**
      * Create Permanent Redirect for old URL key
      */
     if ($product->getId() && isset($productData['url_key_create_redirect'])) {
         $product->setData('save_rewrites_history', (bool) $productData['url_key_create_redirect']);
     }
     /**
      * Check "Use Default Value" checkboxes values
      */
     $useDefaults = $this->request->getPost('use_default');
     if ($useDefaults) {
         foreach ($useDefaults as $attributeCode) {
             $product->setData($attributeCode, false);
         }
     }
     $links = $this->request->getPost('links');
     $links = is_array($links) ? $links : array();
     $linkTypes = array('related', 'upsell', 'crosssell');
     foreach ($linkTypes as $type) {
         if (isset($links[$type])) {
             $links[$type] = $this->jsHelper->decodeGridSerializedInput($links[$type]);
         }
     }
     $product = $this->productLinks->initializeLinks($product, $links);
     /**
      * Initialize product options
      */
     if (isset($productData['options']) && !$product->getOptionsReadonly()) {
         // mark custom options that should to fall back to default value
         $options = $this->mergeProductOptions($productData['options'], $this->request->getPost('options_use_default'));
         $product->setProductOptions($options);
     }
     $product->setCanSaveCustomOptions((bool) $this->request->getPost('affect_product_custom_options') && !$product->getOptionsReadonly());
     return $product;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:65,代码来源:Helper.php

示例4: aroundProcessProduct

 /**
  * Change product type to downloadable if needed
  *
  * @param \Magento\Catalog\Model\Product\TypeTransitionManager $subject
  * @param Closure $proceed
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundProcessProduct(\Magento\Catalog\Model\Product\TypeTransitionManager $subject, Closure $proceed, \Magento\Catalog\Model\Product $product)
 {
     $isTypeCompatible = in_array($product->getTypeId(), array(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE));
     $hasDownloadableData = $this->request->getPost('downloadable');
     if ($isTypeCompatible && $hasDownloadableData && $product->hasIsVirtual()) {
         $product->setTypeId(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE);
         return;
     }
     $proceed($product);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:Downloadable.php

示例5: aroundDispatch

 /**
  * Process massaction key
  *
  * @param \Magento\Backend\App\AbstractAction $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  *
  * @return mixed
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDispatch(\Magento\Backend\App\AbstractAction $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     $key = $request->getPost('massaction_prepare_key');
     if ($key) {
         $postData = $request->getPost($key);
         $value = is_array($postData) ? $postData : explode(',', $postData);
         $request->setPostValue($key, $value ? $value : null);
     }
     return $proceed($request);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:MassactionKey.php

示例6: afterInitialize

 /**
  * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject
  * @param \Magento\Catalog\Model\Product $result
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterInitialize(\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, \Magento\Catalog\Model\Product $result)
 {
     $productData = $this->request->getPost('product');
     /**
      * Create Permanent Redirect for old URL key
      */
     if ($result->getId() && isset($productData['url_key_create_redirect'])) {
         $result->setData('save_rewrites_history', (bool) $productData['url_key_create_redirect']);
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:Helper.php

示例7: execute

 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $productId = $this->request->getParam('id');
     $links = $this->request->getPost('links');
     $links = is_array($links) ? $links : [];
     if (isset($links['question'])) {
         $links['question'] = $this->jsHelper->decodeGridSerializedInput($links['question']);
         $idsCollection = $this->getIdsCollection();
         $idsCollection->addFieldToFilter('product_id', $productId);
         $questionIds = array();
         foreach ($idsCollection as $question) {
             $questionIds[] = $question->getQuestionId();
         }
         //update question position
         foreach ($questionIds as $questionId) {
             if (isset($links['question'][$questionId])) {
                 $idsCollection = $this->getIdsCollection();
                 $idsCollection->addFieldToFilter('question_id', $questionId);
                 $idsCollection->addFieldToFilter('product_id', $productId);
                 $item = $idsCollection->getFirstItem();
                 if ($item->getPosition() != $links['question'][$questionId]['position'] && !empty($links['question'][$questionId]['position'])) {
                     $item->setPosition($links['question'][$questionId]['position']);
                     $item->save();
                 }
             }
         }
         // save new checked questions and position
         $insert = array_diff(array_keys($links['question']), $questionIds);
         if (!empty($insert)) {
             foreach ($insert as $i) {
                 $questionIdModel = $this->questionId->create();
                 $questionIdModel->setProductId((int) $productId);
                 $questionIdModel->setQuestionId($i);
                 $questionIdModel->setPosition($links['question'][$i]['position']);
                 $questionIdModel->save();
             }
         }
         //delete unchecked Questions
         $delete = array_diff($questionIds, array_keys($links['question']));
         if (!empty($delete)) {
             $idsCollection = $this->getIdsCollection();
             $idsCollection->addFieldToFilter('product_id', $productId);
             $idsCollection->addFieldToFilter('question_id', ['in' => $delete]);
             foreach ($idsCollection as $item) {
                 $item->delete();
             }
         }
     }
 }
开发者ID:vladankuzmanovic,项目名称:ProductFaq,代码行数:49,代码来源:SaveQuestions.php

示例8: afterInitialize

 /**
  * Setting Bundle Items Data to product for father processing
  *
  * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject
  * @param \Magento\Catalog\Model\Product $product
  *
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function afterInitialize(\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, \Magento\Catalog\Model\Product $product)
 {
     $compositeReadonly = $product->getCompositeReadonly();
     $selections = $this->request->getPost('bundle_selections');
     if ($selections && !$compositeReadonly) {
         $product->setBundleSelectionsData($selections);
     }
     $items = $this->request->getPost('bundle_options');
     if ($items && !$compositeReadonly) {
         $product->setBundleOptionsData($items);
     }
     $this->processBundleOptionsData($product);
     $this->processDynamicOptionsData($product);
     $affectProductSelections = (bool) $this->request->getPost('affect_bundle_product_selections');
     $product->setCanSaveBundleSelections($affectProductSelections && !$compositeReadonly);
     return $product;
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:28,代码来源:Bundle.php

示例9: setLinkedProducts

 /**
  * Relate simple products to configurable
  *
  * @param ProductInterface $product
  * @param ProductExtensionInterface $extensionAttributes
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 private function setLinkedProducts(ProductInterface $product, ProductExtensionInterface $extensionAttributes)
 {
     $associatedProductIds = $this->request->getPost('associated_product_ids', []);
     $variationsMatrix = $this->request->getParam('variations-matrix', []);
     if (!empty($variationsMatrix)) {
         $generatedProductIds = $this->variationHandler->generateSimpleProducts($product, $variationsMatrix);
         $associatedProductIds = array_merge($associatedProductIds, $generatedProductIds);
     }
     $extensionAttributes->setConfigurableProductLinks(array_filter($associatedProductIds));
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:18,代码来源:Configurable.php

示例10: afterInitialize

 /**
  * Initialize data for configurable product
  *
  * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject
  * @param \Magento\Catalog\Model\Product $product
  *
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterInitialize(\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, \Magento\Catalog\Model\Product $product)
 {
     $attributes = $this->request->getParam('attributes');
     if ($product->getTypeId() == ConfigurableProduct::TYPE_CODE && !empty($attributes)) {
         $setId = $this->request->getPost('new-variations-attribute-set-id');
         $product->setAttributeSetId($setId);
         $this->productType->setUsedProductAttributeIds($attributes, $product);
         $product->setNewVariationsAttributeSetId($setId);
         $associatedProductIds = $this->request->getPost('associated_product_ids', []);
         $variationsMatrix = $this->request->getParam('variations-matrix', []);
         if (!empty($variationsMatrix)) {
             $generatedProductIds = $this->variationHandler->generateSimpleProducts($product, $variationsMatrix);
             $associatedProductIds = array_merge($associatedProductIds, $generatedProductIds);
         }
         $product->setAssociatedProductIds(array_filter($associatedProductIds));
         $product->setCanSaveConfigurableAttributes((bool) $this->request->getPost('affect_configurable_product_attributes'));
     }
     return $product;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:28,代码来源:Configurable.php

示例11: afterInitialize

 /**
  * Setting Bundle Items Data to product for father processing
  *
  * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject
  * @param \Magento\Catalog\Model\Product $product
  *
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function afterInitialize(\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, \Magento\Catalog\Model\Product $product)
 {
     if (($items = $this->request->getPost('bundle_options')) && !$product->getCompositeReadonly()) {
         $product->setBundleOptionsData($items);
     }
     if (($selections = $this->request->getPost('bundle_selections')) && !$product->getCompositeReadonly()) {
         $product->setBundleSelectionsData($selections);
     }
     if ($product->getPriceType() == '0' && !$product->getOptionsReadonly()) {
         $product->setCanSaveCustomOptions(true);
         if ($customOptions = $product->getProductOptions()) {
             foreach (array_keys($customOptions) as $key) {
                 $customOptions[$key]['is_delete'] = 1;
             }
             $product->setProductOptions($customOptions);
         }
     }
     $product->setCanSaveBundleSelections((bool) $this->request->getPost('affect_bundle_product_selections') && !$product->getCompositeReadonly());
     return $product;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:30,代码来源:Bundle.php

示例12: aroundProcessProduct

 /**
  * Change product type to downloadable if needed
  *
  * @param \Magento\Catalog\Model\Product\TypeTransitionManager $subject
  * @param Closure $proceed
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundProcessProduct(\Magento\Catalog\Model\Product\TypeTransitionManager $subject, Closure $proceed, \Magento\Catalog\Model\Product $product)
 {
     $isTypeCompatible = in_array($product->getTypeId(), [\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE]);
     $downloadableData = $this->request->getPost('downloadable');
     $hasDownloadableData = false;
     if (isset($downloadableData)) {
         foreach ($downloadableData as $data) {
             foreach ($data as $rowData) {
                 if (empty($rowData['is_delete'])) {
                     $hasDownloadableData = true;
                     break;
                 }
             }
         }
     }
     if ($isTypeCompatible && $hasDownloadableData && $product->hasIsVirtual()) {
         $product->setTypeId(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE);
         return;
     }
     $proceed($product);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:30,代码来源:Downloadable.php

示例13: afterInitialize

 /**
  * Initialize data for configurable product
  *
  * @param Helper $subject
  * @param ProductInterface $product
  * @return ProductInterface
  * @throws \InvalidArgumentException
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterInitialize(Helper $subject, ProductInterface $product)
 {
     $attributes = $this->request->getParam('attributes');
     $productData = $this->request->getPost('product', []);
     if ($product->getTypeId() !== ConfigurableProduct::TYPE_CODE || empty($attributes)) {
         return $product;
     }
     $setId = $this->request->getPost('new-variations-attribute-set-id');
     if ($setId) {
         $product->setAttributeSetId($setId);
     }
     $extensionAttributes = $product->getExtensionAttributes();
     $product->setNewVariationsAttributeSetId($setId);
     $configurableOptions = [];
     if (!empty($productData['configurable_attributes_data'])) {
         $configurableOptions = $this->optionsFactory->create((array) $productData['configurable_attributes_data']);
     }
     $extensionAttributes->setConfigurableProductOptions($configurableOptions);
     $this->setLinkedProducts($product, $extensionAttributes);
     $product->setCanSaveConfigurableAttributes((bool) $this->request->getPost('affect_configurable_product_attributes'));
     $product->setExtensionAttributes($extensionAttributes);
     return $product;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:33,代码来源:Configurable.php

示例14: afterInitialize

 /**
  * Prepare product to save
  *
  * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject
  * @param \Magento\Catalog\Model\Product $product
  *
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function afterInitialize(\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, \Magento\Catalog\Model\Product $product)
 {
     if ($downloadable = $this->request->getPost('downloadable')) {
         $product->setDownloadableData($downloadable);
         $extension = $product->getExtensionAttributes();
         if (isset($downloadable['link']) && is_array($downloadable['link'])) {
             $links = [];
             foreach ($downloadable['link'] as $linkData) {
                 if (!$linkData || isset($linkData['is_delete']) && $linkData['is_delete']) {
                     continue;
                 } else {
                     $links[] = $this->getLinkBuilder()->setData($linkData)->build($this->getLinkFactory()->create());
                 }
             }
             $extension->setDownloadableProductLinks($links);
         }
         if (isset($downloadable['sample']) && is_array($downloadable['sample'])) {
             $samples = [];
             foreach ($downloadable['sample'] as $sampleData) {
                 if (!$sampleData || isset($sampleData['is_delete']) && (bool) $sampleData['is_delete']) {
                     continue;
                 } else {
                     $samples[] = $this->getSampleBuilder()->setData($sampleData)->build($this->getSampleFactory()->create());
                 }
             }
             $extension->setDownloadableProductSamples($samples);
         }
         $product->setExtensionAttributes($extension);
         if ($product->getLinksPurchasedSeparately()) {
             $product->setTypeHasRequiredOptions(true)->setRequiredOptions(true);
         } else {
             $product->setTypeHasRequiredOptions(false)->setRequiredOptions(false);
         }
     }
     return $product;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:47,代码来源:Downloadable.php

示例15: dispatch

 /**
  * Check if module is enabled
  * If allow only for customer - redirect to login page
  *
  * @param RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  * @throws \Magento\Framework\App\Action\NotFoundException
  */
 public function dispatch(RequestInterface $request)
 {
     /* @var $helper \Magento\Sendfriend\Helper\Data */
     $helper = $this->_objectManager->get('Magento\\Sendfriend\\Helper\\Data');
     /* @var $session \Magento\Customer\Model\Session */
     $session = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
     if (!$helper->isEnabled()) {
         throw new NotFoundException();
     }
     if (!$helper->isAllowForGuest() && !$session->authenticate($this)) {
         $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
         if ($this->getRequest()->getActionName() == 'sendemail') {
             $session->setBeforeAuthUrl($this->_objectManager->create('Magento\\Framework\\UrlInterface')->getUrl('*/*/send', array('_current' => true)));
             $this->_objectManager->get('Magento\\Catalog\\Model\\Session')->setSendfriendFormData($request->getPost());
         }
     }
     return parent::dispatch($request);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:26,代码来源:Product.php


注:本文中的Magento\Framework\App\RequestInterface::getPost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。