當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractModel::getStoreLabels方法代碼示例

本文整理匯總了PHP中Magento\Framework\Model\AbstractModel::getStoreLabels方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractModel::getStoreLabels方法的具體用法?PHP AbstractModel::getStoreLabels怎麽用?PHP AbstractModel::getStoreLabels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Model\AbstractModel的用法示例。


在下文中一共展示了AbstractModel::getStoreLabels方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _afterSave

 /**
  * Save status labels per store
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->hasStoreLabels()) {
         $labels = $object->getStoreLabels();
         $this->getConnection()->delete($this->labelsTable, ['status = ?' => $object->getStatus()]);
         $data = [];
         foreach ($labels as $storeId => $label) {
             if (empty($label)) {
                 continue;
             }
             $data[] = ['status' => $object->getStatus(), 'store_id' => $storeId, 'label' => $label];
         }
         if (!empty($data)) {
             $this->getConnection()->insertMultiple($this->labelsTable, $data);
         }
     }
     return parent::_afterSave($object);
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:24,代碼來源:Status.php

示例2: _saveStoreLabels

 /**
  * Save store labels
  *
  * @param EntityAttribute|\Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _saveStoreLabels(AbstractModel $object)
 {
     $storeLabels = $object->getStoreLabels();
     if (is_array($storeLabels)) {
         $connection = $this->getConnection();
         if ($object->getId()) {
             $condition = ['attribute_id =?' => $object->getId()];
             $connection->delete($this->getTable('eav_attribute_label'), $condition);
         }
         foreach ($storeLabels as $storeId => $label) {
             if ($storeId == 0 || !strlen($label)) {
                 continue;
             }
             $bind = ['attribute_id' => $object->getId(), 'store_id' => $storeId, 'value' => $label];
             $connection->insert($this->getTable('eav_attribute_label'), $bind);
         }
     }
     return $this;
 }
開發者ID:BlackIkeEagle,項目名稱:magento2-continuousphp,代碼行數:25,代碼來源:Attribute.php

示例3: _afterSave

 /**
  * Bind sales rule to customer group(s) and website(s).
  * Save rule's associated store labels.
  * Save product attributes used in rule.
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(AbstractModel $object)
 {
     if ($object->hasStoreLabels()) {
         $this->saveStoreLabels($object->getId(), $object->getStoreLabels());
     }
     // Save product attributes used in rule
     $ruleProductAttributes = array_merge($this->getProductAttributes(serialize($object->getConditions()->asArray())), $this->getProductAttributes(serialize($object->getActions()->asArray())));
     if (count($ruleProductAttributes)) {
         $this->setActualProductAttributes($object, $ruleProductAttributes);
     }
     // Update auto geterated specific coupons if exists
     if ($object->getUseAutoGeneration() && $object->hasDataChanges()) {
         $this->_resourceCoupon->updateSpecificCoupons($object);
     }
     return parent::_afterSave($object);
 }
開發者ID:rafaelstz,項目名稱:magento2,代碼行數:24,代碼來源:Rule.php

示例4: _afterSave

 /**
  * Bind sales rule to customer group(s) and website(s).
  * Save rule's associated store labels.
  * Save product attributes used in rule.
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(AbstractModel $object)
 {
     if ($object->hasStoreLabels()) {
         $this->saveStoreLabels($object->getId(), $object->getStoreLabels());
     }
     if ($object->hasWebsiteIds()) {
         $websiteIds = $object->getWebsiteIds();
         if (!is_array($websiteIds)) {
             $websiteIds = explode(',', (string) $websiteIds);
         }
         $this->bindRuleToEntity($object->getId(), $websiteIds, 'website');
     }
     if ($object->hasCustomerGroupIds()) {
         $customerGroupIds = $object->getCustomerGroupIds();
         if (!is_array($customerGroupIds)) {
             $customerGroupIds = explode(',', (string) $customerGroupIds);
         }
         $this->bindRuleToEntity($object->getId(), $customerGroupIds, 'customer_group');
     }
     // Save product attributes used in rule
     $ruleProductAttributes = array_merge($this->getProductAttributes(serialize($object->getConditions()->asArray())), $this->getProductAttributes(serialize($object->getActions()->asArray())));
     if (count($ruleProductAttributes)) {
         $this->setActualProductAttributes($object, $ruleProductAttributes);
     }
     // Update auto geterated specific coupons if exists
     if ($object->getUseAutoGeneration() && $object->hasDataChanges()) {
         $this->_resourceCoupon->updateSpecificCoupons($object);
     }
     return parent::_afterSave($object);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:38,代碼來源:Rule.php


注:本文中的Magento\Framework\Model\AbstractModel::getStoreLabels方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。