Is it possible to get a value from the environment variables defined at local.properties configuration file and access it via the impex file?
Ex.
$someMacro=<some variable from config>
Thank you!
You can add this to your impex:
# Import config properties into impex macros
UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]
All your configurations from local.properties, etc. are now loaded and can be used via $config- prefix, say for example:
local.properties
your.config.property=322
So your impex would look something like:
# Import config properties into impex macros
UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]
$variable=$config-your.config.property
INSERT_UPDATE SampleItem;code[unique=true];name
;sample1;$variable
# OR you can just directly use the config macro
INSERT_UPDATE SampleItem;code[unique=true];name
;sample1;$config-your.config.property
Hope this works for you.
EDIT: Please also note that if there was no such property found, the value stored on the sample above shall be exactly: $config-your.config.property.
To complete #Atsusa Kai answer, the line with a header alone can be avoided.
It's quite ugly to have this line just to load the properties... but that's actually what is mentionned in the ConfigPropertyImportProcessor class comment :
/**
* Impex ImportProcessor that injects all config properties as impex definitions.
* All defined configuration properties are added as impex macro definitions with
* the prefix of "config-". For example the config key <tt>mail.smtp.server</tt>
* can be accessed via the macro <tt>$config-mail.smtp.server</tt>.
* In order to use this import processor and to load the configuration properties
* the following must be added to the top of the impex file:
*
* <tt>UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]</tt>
*/
The alternative is to used a beanshell command that are tailored for this kind of action.
You can replace the UPDATE GenericItem line by
#%new de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor().init(impex)
but you need to enable code execution.
Related
I have use “Import Definition” bundle to import csv and to create data-objects. (https://github.com/w-vision/ImportDefinitions)
Now I need to put imported data-Object to relevant folders. I need to do it automatically.
eg -
Import first row of the CSV
Check the CSV first row "Category" column value
According to column value need to move into relevant folder.
Setting object path "/products/%Text(mycolumn1);/%Text(mycolumn2);" is not solution to my requirement.
My csv it’s comes with category code not full name.
I need to do some mapping.
eg:-
csv column category value is - OFH
my data-object folder name is Office & Furniture Hardware
I need to match those two and place into correct folder.
What is the best way to do this with “Import Definitions”?
if best way is "interpreter" please let me know how to do it?
Thanks.
There is no much document about Pimcore but I have solve my issue using custom Interpreter.
Here is my solution -
Fist install Import Definition -
https://github.com/w-vision/ImportDefinitions
(it'll install into - /var/www/html/example2.loc/vendor/w-vision/import-definitions/src/ImportDefinitionsBundle/)
composer require w-vision/import-definitions:^2.0-dev
bin/console pimcore:bundle:enable ImportDefinitionsBundle
bin/console pimcore:bundle:install ImportDefinitionsBundle
Add new custom Interpreter
Add "categorymap.js" to
/var/www/html/example2.loc/vendor/w-vision/import-definitions/src/ImportDefinitionsBundle/Resources/public/pimcore/js/interpreters/categorymap.js
Add "CategoryMap.php" to
/var/www/html/example2.loc/vendor/w-vision/import-definitions/src/ImportDefinitionsBundle/Interpreter/CategoryMap.php
Add "CategoryMapInterpreterType.php" to
/var/www/html/example2.loc/vendor/w-vision/import-definitions/src/ImportDefinitionsBundle/Form/Type/Interpreter/CategoryMapInterpreterType.php
Update Service.yml in -
/var/www/html/example2.loc/vendor/w-vision/import-definitions/src/ImportDefinitionsBundle/Resources/config/services.yml
adding Following -
import_definition.interpreter.category_map:
class: ImportDefinitionsBundle\Interpreter\CategoryMap
tags:
- { name: import_definition.interpreter, type: category_map, form-type: ImportDefinitionsBundle\Form\Type\Interpreter\CategoryMapInterpreterType }
Update config.yml in -
adding follwing -
interpreter_categorymap: '/bundles/importdefinitions/pimcore/js/interpreters/categorymap.js'
To csv upload run following CLI command -
bin/console import-definitions:import -d 1 -p "{\"file\":\"sap_export1.csv\"}"
I need to import impex lines through cronjob for which I have written below code,
Code
I am writing this code in public PerformResult perform(final CronJobModel arg0). If I import this impex manaully from hac, it gets imported successfully. Following is the error I am getting on logs,
log error
Thanks...
I would strongly recommend using ModelService for implementations like this.
secFilingsComponent.setName("2014 Filings 1");
secFilingsComponent.setUrlLink("#");
secFilingsComponent.setSlots(CollectionUtils.union(oldSlots, newSlots));
modelService.save(secFilingsComponent);
If the changes you want to do should only be executed once, I would recommend using hmc/backoffice and do them manually or execute the Impex in the hac:
https://localhost:9002/hac/console/impex/import
I think that you have to replace cmsComponents(&componentRef) by cmsComponents(uid,$contentCV) in the first INSERT_UPDATE.
I've placed my customised template in : advanced_search.post.tpl file in \cscart\design\backend\templates\addons\codes_searching\hooks\common\advanced_search.
: {include file="buttons/button.tpl" but_text=__("search_products") but_onclick=$but_onclick but_href=$but_href but_role="submit-button" but_name=$but_name}
It doesn't work, please help me!
If there is no placed hook on default advanced_search.tpl file, it doesn't work to creating advanced_search.post.tpl hook file.
Your have only one way that override template.Because there is no hook to hooking.
You must create
backend\templates\addons\codes_searching\overrides\common\advanced_search.tpl
file.
Then copy default advanced_search.tpl file content to overriding content, and do your changes.
I have a very simple use for puppet; I create and delete students from a test server. I would like to store some configuration variables in another file and then just do a simple: include 'variables.pp' at the top of my manifest file. Is there a simple way to do this? I have consulted:
https://docs.puppet.com/puppet/latest/reference/lang_classes.html#using-include
https://puppet.com/blog/problem-separating-data-from-puppet-code
None of which give a simple solution. If I can only use the solutions above, I'll just hardcode it in my manifest.
Puppet 3 has an import statement that should serve your purpose. It is deprecated (and removed from Puppet 4), but it will do the job for you in Puppet 3:
variables.pp
# top-scope variables:
$var1 = 'foo'
$var2 = 'bar'
main.pp
import 'variables.pp'
# demo
notify { "var1 = ${var1}; var2 = ${var2}": }
Note that Puppet's import does not perform text interpolation; it is more like Python's import, making complete declarations from another manifest visible in the importing manifest.
i started to use Soapui this week and i did some tests like sending a request POST and save the response as txt file ina folder.
What i'm trying to do is to read this txt file, copy a sepcific data and store it in Custom Properties.
Because i want to use this object in the nest Request POST which is depending of the first request.
I want to do it in Groovy.
i have only the Open source SOAPUI version 5.0.0
Thank you
You've to add a groovy test step in your test case and do it similar as you would in java, check groovy documentation.
Only as a reference SOAPUI 5.2.0 has the groovy 2.1.7 version (check the dependency in pom.xml) so in groovy scripts which runs on SOAPUI you can use the java standard api included in the jre, the SOAPUI classes, the groovy 2.1.7 API among some others, additionally you can include other jars in SOAPUI\bin\ext in order to use them in groovy script.
Finally you're asking about to read some data from a file and write it to a custom property, so for example you can do it as follows:
// read the file from path
def file = new File('/path/yourFile')
// for example read line by line
def yourData = file.eachLine { line ->
// check if the line contains your data
if(line.contains('mySpecifiyData=')){
return line
}
}
// put the line in a custom property in the testCase
testRunner.testCase.setPropertyValue('yourProp',yourData)
Since your problem it's not clear I show you a possible sample showing how to read a file looking for specific content and saving this content in a custom property in the testCase.
Note that in groovy scripts the are a global objects which you can use: testRunner, context and log, in this sample I use testRunner to access testCase and its properties, in the same way you can go thought testRunner to access testSuites, project, testSteps etc... check the documentation:
http://www.soapui.org/Scripting-Properties/tips-a-tricks.html
http://www.soapui.org/Functional-Testing/working-with-scripts.html
Hope this helps,