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


PHP Helper\Data类代码示例

本文整理汇总了PHP中Magento\Catalog\Helper\Data的典型用法代码示例。如果您正苦于以下问题:PHP Data类的具体用法?PHP Data怎么用?PHP Data使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _prepareLayout

 /**
  * Load Wysiwyg on demand and prepare layout
  *
  * @return void
  */
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     if ($this->_catalogData->isModuleEnabled('Magento_Cms') && $this->_wysiwygConfig->isEnabled()) {
         $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Attributes.php

示例2: afterSave

 /**
  * Processing object before save data
  *
  * @return $this
  */
 public function afterSave()
 {
     if (!$this->_catalogData->isPriceGlobal() && $this->getWebsiteId()) {
         $this->getResource()->saveSelectionPrice($this);
         if (!$this->getDefaultPriceScope()) {
             $this->unsSelectionPriceValue();
             $this->unsSelectionPriceType();
         }
     }
     parent::afterSave();
 }
开发者ID:opexsw,项目名称:magento2,代码行数:16,代码来源:Selection.php

示例3: _prepareCollection

 /**
  * @return Grid
  */
 protected function _prepareCollection()
 {
     $productId = $this->getRequest()->getParam('id');
     $websiteId = 0;
     if ($store = $this->getRequest()->getParam('store')) {
         $websiteId = $this->_storeManager->getStore($store)->getWebsiteId();
     }
     if ($this->_catalogData->isModuleEnabled('Magento_ProductAlert')) {
         $collection = $this->_priceFactory->create()->getCustomerCollection()->join($productId, $websiteId);
         $this->setCollection($collection);
     }
     return parent::_prepareCollection();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Price.php

示例4: setUp

 protected function setUp()
 {
     $this->_helper = $this->getMock('Magento\\Catalog\\Helper\\Data', array('isPriceGlobal'), array(), '', false);
     $this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true));
     $loggerMock = $this->getMock('Magento\\Framework\\Logger', array(), array(), '', false);
     $currencyFactoryMock = $this->getMock('Magento\\Directory\\Model\\CurrencyFactory', array(), array(), '', false);
     $storeManagerMock = $this->getMock('Magento\\Framework\\StoreManagerInterface', array(), array(), '', false);
     $productTypeMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type', array(), array(), '', false);
     $configMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $this->_model = $this->getMockForAbstractClass('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Groupprice\\AbstractGroupprice', array('logger' => $loggerMock, 'currencyFactory' => $currencyFactoryMock, 'storeManager' => $storeManagerMock, 'catalogData' => $this->_helper, 'config' => $configMock, 'catalogProductType' => $productTypeMock));
     $resource = $this->getMock('StdClass', array('getMainTable'));
     $resource->expects($this->any())->method('getMainTable')->will($this->returnValue('table'));
     $this->_model->expects($this->any())->method('_getResource')->will($this->returnValue($resource));
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:14,代码来源:AbstractTest.php

示例5: _prepareLayout

 /**
  * Preparing layout
  *
  * @return \Magento\Catalog\Block\Breadcrumbs
  */
 protected function _prepareLayout()
 {
     if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
         $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'title' => __('Go to Home Page'), 'link' => $this->_storeManager->getStore()->getBaseUrl()]);
         $title = [];
         $path = $this->_catalogData->getBreadcrumbPath();
         foreach ($path as $name => $breadcrumb) {
             $breadcrumbsBlock->addCrumb($name, $breadcrumb);
             $title[] = $breadcrumb['label'];
         }
         $this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($title)));
     }
     return parent::_prepareLayout();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:Breadcrumbs.php

示例6: execute

 /**
  * Set Quote information about MSRP price enabled
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var $quote \Magento\Sales\Model\Quote */
     $quote = $observer->getEvent()->getQuote();
     $canApplyMsrp = false;
     if ($this->catalogData->isMsrpEnabled()) {
         foreach ($quote->getAllAddresses() as $address) {
             if ($address->getCanApplyMsrp()) {
                 $canApplyMsrp = true;
                 break;
             }
         }
     }
     $quote->setCanApplyMsrp($canApplyMsrp);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:21,代码来源:SetCanApplyMsrp.php

示例7: canApplyMsrp

 /**
  * Check if can apply msrp to totals
  *
  * @return bool
  */
 public function canApplyMsrp()
 {
     if (!$this->getQuote()->hasCanApplyMsrp() && $this->_catalogData->isMsrpEnabled()) {
         $this->getQuote()->collectTotals();
     }
     return $this->getQuote()->getCanApplyMsrp();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:AbstractCart.php

示例8: getItems

 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getItems()
 {
     Profiler::start(__METHOD__);
     $items = [];
     /** @var \Magento\Catalog\Model\Product $product */
     foreach ($this->collection as $product) {
         $item = ['sku' => $product->getSku(), 'name' => $product->getName(), 'url' => $product->getProductUrl(), 'description' => null, 'image' => null, 'price' => null, 'rating' => null];
         if ($this->config->isShowShortDescription()) {
             $item['description'] = html_entity_decode(strip_tags($product->getDataUsingMethod('description')));
         }
         $image = false;
         if ($product->getImage() && $product->getImage() != 'no_selection') {
             $image = $product->getImage();
         } elseif ($product->getSmallImage() && $product->getSmallImage() != 'no_selection') {
             $image = $product->getSmallImage();
         }
         if ($this->config->isShowImage() && $image) {
             $item['image'] = $this->imageHelper->init($product, false)->setImageFile($image)->resize(65 * 2, 80 * 2)->getUrl();
         }
         if ($this->config->isShowPrice()) {
             $item['price'] = $this->catalogHelper->getTaxPrice($product, $product->getFinalPrice());
             $item['price'] = $this->pricingHelper->currency($item['price'], false, false);
         }
         if ($this->config->isShowRating()) {
             $item['rating'] = $this->reviewRenderer->getReviewsSummaryHtml($product, ReviewRendererInterface::SHORT_VIEW);
         }
         $items[] = $item;
     }
     Profiler::stop(__METHOD__);
     return $items;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:Product.php

示例9: beforeSave

 /**
  * Disable MAP if it's bundle with dynamic price type
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return $this
  */
 public function beforeSave($product)
 {
     if (!$product instanceof \Magento\Catalog\Model\Product || $product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE || $product->getPriceType() != \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC) {
         return parent::beforeSave($product);
     }
     parent::beforeSave($product);
     $attributeCode = $this->getAttribute()->getName();
     $value = $product->getData($attributeCode);
     if (empty($value)) {
         $value = $this->_catalogData->isMsrpApplyToAll();
     }
     if ($value) {
         $product->setData($attributeCode, 0);
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:22,代码来源:Msrp.php

示例10: setUp

 protected function setUp()
 {
     $this->_helper = $this->getMock('Magento\\Catalog\\Helper\\Data', ['isPriceGlobal'], [], '', false);
     $this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true));
     $currencyFactoryMock = $this->getMock('Magento\\Directory\\Model\\CurrencyFactory', ['create'], [], '', false);
     $storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface', [], [], '', false);
     $productTypeMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type', [], [], '', false);
     $configMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $localeFormatMock = $this->getMock('\\Magento\\Framework\\Locale\\FormatInterface', [], [], '', false);
     $groupManagement = $this->getMock('Magento\\Customer\\Api\\GroupManagementInterface', [], [], '', false);
     $metadataPool = $this->getMock('Magento\\Framework\\Model\\Entity\\MetadataPool', [], [], '', false);
     $this->_model = $this->getMockForAbstractClass('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\GroupPrice\\AbstractGroupPrice', ['currencyFactory' => $currencyFactoryMock, 'storeManager' => $storeManagerMock, 'catalogData' => $this->_helper, 'config' => $configMock, 'localeFormat' => $localeFormatMock, 'catalogProductType' => $productTypeMock, 'groupManagement' => $groupManagement, 'metadataPool' => $metadataPool]);
     $resource = $this->getMock('StdClass', ['getMainTable']);
     $resource->expects($this->any())->method('getMainTable')->will($this->returnValue('table'));
     $this->_model->expects($this->any())->method('_getResource')->will($this->returnValue($resource));
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:16,代码来源:AbstractTest.php

示例11: getStockOption

 /**
  * Retrieve stock option array
  *
  * @return array
  */
 public function getStockOption()
 {
     if ($this->catalogData->isModuleEnabled('Magento_CatalogInventory')) {
         return $this->stock->toOptionArray();
     }
     return array();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Inventory.php

示例12: _prepareColumns

 /**
  * @return $this
  */
 protected function _prepareColumns()
 {
     $this->addColumn('entity_id', array('header' => __('ID'), 'type' => 'number', 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id'));
     $this->addColumn('name', array('header' => __('Name'), 'index' => 'name', 'class' => 'xxx'));
     $store = $this->_getStore();
     if ($store->getId()) {
         $this->addColumn('custom_name', array('header' => __('Name in %1', $store->getName()), 'index' => 'custom_name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name'));
     }
     $this->addColumn('type', array('header' => __('Type'), 'index' => 'type_id', 'type' => 'options', 'options' => $this->_type->getOptionArray()));
     $sets = $this->_setsFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash();
     $this->addColumn('set_name', array('header' => __('Attribute Set'), 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, 'header_css_class' => 'col-attr-name', 'column_css_class' => 'col-attr-name'));
     $this->addColumn('sku', array('header' => __('SKU'), 'index' => 'sku'));
     $store = $this->_getStore();
     $this->addColumn('price', array('header' => __('Price'), 'type' => 'price', 'currency_code' => $store->getBaseCurrency()->getCode(), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price'));
     if ($this->_catalogData->isModuleEnabled('Magento_CatalogInventory')) {
         $this->addColumn('qty', array('header' => __('Quantity'), 'type' => 'number', 'index' => 'qty'));
     }
     $this->addColumn('visibility', array('header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->_visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility'));
     $this->addColumn('status', array('header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray()));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $this->addColumn('websites', array('header' => __('Websites'), 'sortable' => false, 'index' => 'websites', 'type' => 'options', 'options' => $this->_websiteFactory->create()->getCollection()->toOptionHash(), 'header_css_class' => 'col-websites', 'column_css_class' => 'col-websites'));
     }
     $this->addColumn('edit', array('header' => __('Edit'), 'type' => 'action', 'getter' => 'getId', 'actions' => array(array('caption' => __('Edit'), 'url' => array('base' => '*/*/edit', 'params' => array('store' => $this->getRequest()->getParam('store'))), 'field' => 'id')), 'filter' => false, 'sortable' => false, 'index' => 'stores', 'header_css_class' => 'col-action', 'column_css_class' => 'col-action'));
     if ($this->_catalogData->isModuleEnabled('Magento_Rss')) {
         $this->addRssList('rss/catalog/notifystock', __('Notify Low Stock RSS'));
     }
     return parent::_prepareColumns();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:31,代码来源:Grid.php

示例13: collect

 /**
  * Collect information about MSRP price enabled
  *
  * @param  \Magento\Sales\Model\Quote\Address $address
  * @return $this
  */
 public function collect(\Magento\Sales\Model\Quote\Address $address)
 {
     parent::collect($address);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $canApplyMsrp = false;
     foreach ($items as $item) {
         if (!$item->getParentItemId() && $this->_catalogData->canApplyMsrp($item->getProductId(), \Magento\Catalog\Model\Product\Attribute\Source\Msrp\Type::TYPE_BEFORE_ORDER_CONFIRM, true)) {
             $canApplyMsrp = true;
             break;
         }
     }
     $address->setCanApplyMsrp($canApplyMsrp);
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:23,代码来源:Msrp.php

示例14: saveItemTitleAndPrice

 /**
  * Save title and price of link item
  *
  * @param \Magento\Downloadable\Model\Link $linkObject
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function saveItemTitleAndPrice($linkObject)
 {
     $connection = $this->getConnection();
     $linkTitleTable = $this->getTable('downloadable_link_title');
     $linkPriceTable = $this->getTable('downloadable_link_price');
     $select = $connection->select()->from($this->getTable('downloadable_link_title'))->where('link_id=:link_id AND store_id=:store_id');
     $bind = [':link_id' => $linkObject->getId(), ':store_id' => (int) $linkObject->getStoreId()];
     if ($connection->fetchOne($select, $bind)) {
         $where = ['link_id = ?' => $linkObject->getId(), 'store_id = ?' => (int) $linkObject->getStoreId()];
         if ($linkObject->getUseDefaultTitle()) {
             $connection->delete($linkTitleTable, $where);
         } else {
             $insertData = ['title' => $linkObject->getTitle()];
             $connection->update($linkTitleTable, $insertData, $where);
         }
     } else {
         if (!$linkObject->getUseDefaultTitle()) {
             $connection->insert($linkTitleTable, ['link_id' => $linkObject->getId(), 'store_id' => (int) $linkObject->getStoreId(), 'title' => $linkObject->getTitle()]);
         }
     }
     $select = $connection->select()->from($linkPriceTable)->where('link_id=:link_id AND website_id=:website_id');
     $bind = [':link_id' => $linkObject->getId(), ':website_id' => (int) $linkObject->getWebsiteId()];
     if ($connection->fetchOne($select, $bind)) {
         $where = ['link_id = ?' => $linkObject->getId(), 'website_id = ?' => $linkObject->getWebsiteId()];
         if ($linkObject->getUseDefaultPrice()) {
             $connection->delete($linkPriceTable, $where);
         } else {
             $connection->update($linkPriceTable, ['price' => $linkObject->getPrice()], $where);
         }
     } else {
         if (!$linkObject->getUseDefaultPrice()) {
             $dataToInsert[] = ['link_id' => $linkObject->getId(), 'website_id' => (int) $linkObject->getWebsiteId(), 'price' => (double) $linkObject->getPrice()];
             if ($linkObject->getOrigData('link_id') != $linkObject->getLinkId()) {
                 $_isNew = true;
             } else {
                 $_isNew = false;
             }
             if ($linkObject->getWebsiteId() == 0 && $_isNew && !$this->_catalogData->isPriceGlobal()) {
                 $websiteIds = $linkObject->getProductWebsiteIds();
                 foreach ($websiteIds as $websiteId) {
                     $baseCurrency = $this->_configuration->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default');
                     $websiteCurrency = $this->_storeManager->getWebsite($websiteId)->getBaseCurrencyCode();
                     if ($websiteCurrency == $baseCurrency) {
                         continue;
                     }
                     $rate = $this->_createCurrency()->load($baseCurrency)->getRate($websiteCurrency);
                     if (!$rate) {
                         $rate = 1;
                     }
                     $newPrice = $linkObject->getPrice() * $rate;
                     $dataToInsert[] = ['link_id' => $linkObject->getId(), 'website_id' => (int) $websiteId, 'price' => $newPrice];
                 }
             }
             $connection->insertMultiple($linkPriceTable, $dataToInsert);
         }
     }
     return $this;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:65,代码来源:Link.php

示例15: testSavePrices

 public function testSavePrices()
 {
     $rowSet = [0 => ['value_id' => '1', 'product_super_attribute_id' => '1', 'value_index' => '12', 'is_percent' => '0', 'pricing_value' => '3.0000', 'website_id' => '0'], 1 => ['value_id' => '2', 'product_super_attribute_id' => '1', 'value_index' => '13', 'is_percent' => '0', 'pricing_value' => '8.0000', 'website_id' => '0']];
     $values = [12 => ['value_index' => '12', 'pricing_value' => '', 'is_percent' => '0', 'include' => '1'], 13 => ['value_index' => '13', 'pricing_value' => '5', 'is_percent' => '0', 'include' => '1'], 14 => ['value_index' => '14', 'pricing_value' => '3', 'is_percent' => '0', 'include' => '1']];
     $attribute = $this->getMockBuilder('Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable\\Attribute')->setMethods(['getValues', 'getId'])->disableOriginalConstructor()->getMock();
     $adapterMock = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMock();
     $selectMock = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock();
     $this->resource->expects($this->once())->method('getConnection')->with('core_write')->willReturn($adapterMock);
     $this->catalogData->expects($this->any())->method('isPriceGlobal')->willReturn(1);
     $attribute->expects($this->once())->method('getValues')->willReturn($values);
     $adapterMock->expects($this->once())->method('select')->willReturn($selectMock);
     $selectMock->expects($this->once())->method('from')->with(null)->will($this->returnSelf());
     $selectMock->expects($this->at(1))->method('where')->with('product_super_attribute_id = :product_super_attribute_id')->will($this->returnSelf());
     $selectMock->expects($this->at(2))->method('where')->with('website_id = :website_id')->will($this->returnSelf());
     $attribute->expects($this->any())->method('getId')->willReturn(1);
     $adapterMock->expects($this->once())->method('fetchAll')->with($selectMock, ['product_super_attribute_id' => 1, 'website_id' => 0])->willReturn($rowSet);
     $this->assertEquals($this->model, $this->model->savePrices($attribute));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:AttributeTest.php


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