Пример #1
0
 /**
  * @return array
  */
 private function getAsOptionArray()
 {
     if (!isset($this->_asOptionArray)) {
         /** @var array $optionCurrenciesAll */
         $optionCurrenciesAll = Mage::app()->getLocale()->getOptionCurrencies();
         df_assert_array($optionCurrenciesAll);
         /** @var array $optionCurrencyMap */
         $optionCurrencyMap = array_combine(df_column($optionCurrenciesAll, 'value'), df_column($optionCurrenciesAll, 'label'));
         df_assert_array($optionCurrencyMap);
         /** @var array $result */
         $result = array();
         foreach (self::getAllowedCurrencies() as $currencyCode) {
             /** @var string $currencyCode */
             /** @var string|null $label  */
             $label = df_a($optionCurrencyMap, $currencyCode);
             if (!is_null($label)) {
                 $result[] = array('value' => $currencyCode, 'label' => $label);
             }
         }
         df_assert_array($result);
         $this->_asOptionArray = $result;
     }
     df_result_array($this->_asOptionArray);
     return $this->_asOptionArray;
 }
Пример #2
0
 /**
  * @return array
  */
 private function getPost()
 {
     if (!isset($this->_post)) {
         /** @var array $result  */
         $result = df()->request()->filterDates(df()->request()->getController()->getRequest()->getPost(), array('from_date', 'to_date'));
         df_assert_array($result);
         $this->_post = $result;
     }
     df_result_array($this->_post);
     return $this->_post;
 }
Пример #3
0
 /**
  * @return array
  */
 private function getValue()
 {
     /** @var array $result  */
     $result = array('url' => df_helper()->yandexMarket()->preprocessUrl($this->getProduct()->getProductUrl()), 'price' => $this->getPriceAsText(), 'currencyId' => $this->getSettings()->general()->getCurrency()->getId(), 'categoryId' => $this->getCategoryId());
     if (!is_null($this->getProduct()->getData('image'))) {
         $result['picture'] = df_helper()->yandexMarket()->preprocessUrl($this->getProduct()->getMediaConfig()->getMediaUrl($this->getProduct()->getData('image')));
     }
     if (!$this->hasVendorInfo()) {
         $result['name'] = Df_Varien_Simplexml_Element::markAsCData($this->getProduct()->getName());
     } else {
         $result = array_merge($result, array('vendor' => $this->getProduct()->getAttributeText('manufacturer'), 'vendorCode' => $this->getProduct()->getData('manufacturer'), 'model' => Df_Varien_Simplexml_Element::markAsCData($this->getProduct()->getName()), 'description' => Df_Varien_Simplexml_Element::markAsCData(df_convert_null_to_empty_string($this->getProduct()->getData('description')))));
     }
     if (!is_null($this->getProduct()->getData('country_of_manufacture'))) {
         $result['country_of_origin'] = $this->getProduct()->getAttributeText('country_of_manufacture');
     }
     if ($this->getSettings()->general()->hasPointsOfSale()) {
         $result = array_merge($result, array('store' => df_output()->convertBooleanToString($this->getProduct()->isSalable()), 'pickup' => df_output()->convertBooleanToString($this->getSettings()->general()->isPickupAvailable()), 'delivery' => df_output()->convertBooleanToString(true)));
     }
     df_result_array($result);
     return $result;
 }
Пример #4
0
 /**
  * 2015-12-07
  * 2016-01-01
  * Сегодня заметил, что Magento 2, в отличие от Magento 1.x,
  * допускает иерархическую вложенность групп настроек большую, чем 3, например:
  * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Cron/etc/adminhtml/system.xml#L14
  * В Magento 1.x вложенность всегда такова: section / group / field.
  * В Magento 2 вложенность может быть такой: section / group / group / field.
  * @return array(string => mixed)
  */
 protected function value()
 {
     return dfc($this, function () {
         /** @var string[] $pathA */
         $pathA = array_slice(df_explode_xpath($this->getPath()), 1);
         /** @var string $fieldName */
         $fieldName = array_pop($pathA);
         /** @var string $path */
         $path = 'groups/' . implode('/groups/', $pathA) . '/fields/' . $fieldName;
         /** @var array(string => mixed) $result */
         /**
          * 2016-09-02
          * При сохранении настроек вне области действия по умолчанию
          * в результат попадает ключ «inherit». Удаляем его.
          * https://code.dmitry-fedyuk.com/m2e/allpay/issues/24
          */
         $result = dfa_unset(dfa_deep($this->_data, $path), 'inherit');
         df_result_array($result);
         return $result;
     });
 }
Пример #5
0
 /**
  * 2015-11-27
  * @return array(string => mixed)
  * @throws \Exception
  */
 private function responseA()
 {
     if (!isset($this->{__METHOD__})) {
         /** @var bool $debug */
         $debug = true;
         /** @var array(string => mixed) $result */
         $result = df_json_decode($debug || !S::s()->serverApiKey() ? df_http_get('https://mage2.pro/google-fonts.json') : df_http_get('https://www.googleapis.com/webfonts/v1/webfonts', ['key' => S::s()->serverApiKey(), 'sort' => 'alpha']));
         /**
         * 2015-11-17
         * В документации об этом ни слова не сказано,
         * однако в случае сбоя Google API возвращает JSON следующией структуры:
         				{
         					error: {
         						errors: [
         							{
         								domain: "usageLimits",
         								reason: "accessNotConfigured",
         								message: "Access Not Configured. The API (Google Fonts Developer API) is not enabled for your project. Please use the Google Developers Console to update your configuration.",
         								extendedHelp: "https://console.developers.google.com"
         							}
         						],
         						code: 403,
         						message: "Access Not Configured. The API (Google Fonts Developer API) is not enabled for your project. Please use the Google Developers Console to update your configuration."
         					}
         				}
         * https://developers.google.com/fonts/docs/developer_api
         */
         /** @var array(string => mixed)|null $result */
         $error = dfa($result, 'error');
         if ($error) {
             throw (new Exception($error))->standard();
         }
         /**
          * 2015-11-27
          * https://developers.google.com/fonts/docs/developer_api#Example
          */
         $result = dfa($result, 'items');
         df_result_array($result);
         $this->{__METHOD__} = $result;
     }
     return $this->{__METHOD__};
 }
Пример #6
0
 /**
  * @param string|string[] $path
  * @return X[]
  */
 public function xpathA($path)
 {
     if (1 < func_num_args()) {
         $path = df_cc_path(func_get_args());
     } else {
         if (is_array($path)) {
             $path = df_cc_path($path);
         }
     }
     df_param_string_not_empty($path, 0);
     /** @var X[] $result */
     $result = parent::xpath($path);
     df_result_array($result);
     return $result;
 }
Пример #7
0
 /**
  * @return array
  */
 private function getDocumentData_Shop()
 {
     /** @var array $result  */
     $result = array('name' => $this->getSettings()->shop()->getNameForClients(), 'company' => $this->getSettings()->shop()->getNameForAdministration(), 'url' => df_helper()->yandexMarket()->preprocessUrl($this->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)), 'platform' => 'Российская сборка Magento', 'version' => rm_version(), 'agency' => $this->getSettings()->shop()->getAgency(), 'email' => $this->getSettings()->shop()->getSupportEmail(), 'currencies' => array('currency' => $this->getDocumentData_Currencies()), 'categories' => array('category' => $this->getDocumentData_Categories()));
     if (!is_null($this->getSettings()->general()->getLocalDeliveryCost())) {
         $result['local_delivery_cost'] = $this->getSettings()->general()->getLocalDeliveryCost();
     }
     $result['offers'] = array('offer' => $this->getDocumentData_Offers());
     df_result_array($result);
     return $result;
 }
Пример #8
0
/**
* 2016-11-04
* Returns an associative array like:
	{
		"SCHEMA_NAME": null,
		"TABLE_NAME": "customer_group",
		"COLUMN_NAME": "test_7781",
		"COLUMN_POSITION": 11,
		"DATA_TYPE": "varchar",
		"DEFAULT": null,
		"NULLABLE": true,
		"LENGTH": "255",
		"SCALE": null,
		"PRECISION": null,
		"UNSIGNED": null,
		"PRIMARY": false,
		"PRIMARY_POSITION": null,
		"IDENTITY": false
	}
* @param string $table
* @param string $column
* @return array(string => string|int|null)
*/
function df_db_column_describe($table, $column)
{
    /** @var array(string => string|int|null) $result */
    $result = dfa(df_conn()->describeTable(df_table($table)), $column);
    df_result_array($result);
    return $result;
}