How to hide a user property in ATG BCC UI using ViewMappingRepository - oracle

I am new to ViewMappingRepository. I need to hide one user property in ATG BCC user screen tab. how to hide the property? .
<property name="lastPurchasedCost" data-type="string" display-name="Last Purchased Cost" />

First need to create a new attribute value for hide a property in ViewMappingRepository.
<add-item item-descriptor="attributeValue" id="AmAvHideUsersGeneralProp">
<set-property name="value"><![CDATA[lastPurchasedCost]]></set-property>
</add-item>
My property is shown under the user general category. So print that category ItemViewMapping and update your created new attributeValue id set to excludedProperties value.
<add-item item-descriptor="itemViewMapping" id="AmIvmUsersGeneral">
<set-property name="attributeValues"><![CDATA[excludedProperties=AmAvHideUsersGeneralProp]]></set-property>
</add-item>
Note: If already set any of the attributeValue to excludedProperties you need to add only you property name to the existing attributeValue inside set-property value.

Related

How to filter with custom column in sales_order_grid.xml in magento 2?

I create a custom grid columns for sales_order_grid.xml in magento 2. I created file app/code/MyApp/Sales/view/adminhtml/ui_component/sales_order_grid.xml and add below code:
This column will display country name of the order.
<column name="purchase_from" class="MyApp\Sales\Ui\Component\Listing\Column\Order\PurchaseFrom">
<settings>
<label translate="true">Purchase Point</label>
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
<sortable>false</sortable>
<filter>select</filter>
<options class="MyApp\Sales\Ui\Component\Listing\Column\Order\PurchaseFrom\Options"/>
<dataType>select</dataType>
</settings>
</column>
So, I create file app/code/MyApp/Sales/Ui/Component/Listing/Column/Order/PurchaseFrom.php with prepareDataSource function to get country name from order ID.
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item) {
$orderId = $item['entity_id'];
$item[$fieldName] = $this->getCountryName($orderId);
}
}
return $dataSource;
}
So, I created options class for user select country in the filter.
app/code/MyApp/Sales/Ui/Component/Listing/Column/Order/PurchaseFrom/Options.php
The country name so on grid and display on filter select are OK.
But when I click Apply filter it displays popup "Attention Something went wrong.". and string on page
"Something went wrong with processing the default view and we have restored the filter to its original state."
How filter with custom column value in sales_order_grid ?
Please help me,
Thank you so much,
BienHV

Download raw data in Joomla component

I have written a Joomla component which is working well. I now want to add a button to an admin list view that when clicked automatically starts a CSV download of only the items selected in the list.
I'm OK with the model logic, the problem I've got is passing the selected cids or presenting raw output without the template.
If I use JToolBar's appendButton function to add a 'Link' type button, then I can send the user to a URL with 'format=raw', but I can't send information about which items were checked.
If I use JToolBarHelper::custom to add a custom list button, then I can send the information about which buttons were checked, but I can't send format=raw
As far as I can see there are two solutions, but I don't know how to implement either of them. Option one would be to force templateless raw output without a URL parameter of format=raw. Option two would be to set a hidden variable with format=raw in the admin form.
Any help would be appreciated
I've solved this as follows:
I added this hidden field to the admin form
<input type="hidden" name="format" value="html" />
Then subclassed JToolbarButtonStandard overriding the _getCommand with
protected function _getCommand($name,$task,$list)
{
JHtml::_('behavior.framework');
$message = JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
$message = addslashes($message);
if ($list)
{
$cmd = "if (document.adminForm.boxchecked.value==0){alert('$message');}else{document.getElementById('adminForm').format.value='raw'; Joomla.submitbutton('$task')}";
}
else
{
$cmd = "document.getElementById('adminForm').format.value='raw'; Joomla.submitbutton('$task')";
}
return $cmd;
}
So that when the button was clicked it changed the format parameter from html to raw.
I'm not going to mark this as solved in case anyone has any better ideas

Server side validation in module setting page in backend joomla

I am using joomla 2.5, i am working on joomla module, i want to perform server side custom form validation at backend setting page in module. I have checked joomla forums , but they all explained according to component , i strictly need to do it in module . I am new in joomla . Please explain the method.
Try this,
First of all you can't do a wide variety of validations like components forms in module params without hacking the core.
the available options are limiting INT,RAW data string only.
you can use the last option of module params called filter. Details take a look at this.
<field name="myintvalue" type="text" default="8" label="Enter some text" description="Enter some description" filter="integer" />
<field name="myhtmlvalue" type="text" default="" label="Enter some text" description="Enter some description" filter="raw" />
Alternate Options.
You can create a custom rule for validation. For example your module name is mod_mymodule:
Add addrulepath attribute to the fieldset in the .xml file:
addrulepath="modules/mod_mymodule"
This will be the path to the custom rule folder.
Add validate attribute to the field with the name of the rule file:
validate="testint"
This will give us the file testint.php.
Create the rule file testint.php and put it to the path specified in the addrulepath attribute. So the full path will be:
administrator/modules/mod_mymodule/testint.php
Here is a simple validation rule class:
class JFormRuleTestint extends JFormRule
{
public function test(&$element, $value, $group = null, &$input = null, &$form = null)
{
return ((int)$value > 0 && (int)$value < 2);
}
}
it should extend JFormRule class and you will need only one method, called test. $value will contain the input from the field. Here we are testing it to be integer between 0 and 2.
Hope its helps..

delete custom customer attribute in magento

I have created a custom attribute for customer in Magento.
I have accidentally set wrong type for my attribute.
Now I want to either modify this attribute or delete this one and then create new attribute.
Can any one tell me whether I can delete or modify custom attribute in magneto or not?
Thanks in advance.
You can create an upgrade script in one of your modules with this content:
$this->updateAttribute('customer', 'attribute_code_here', 'type', 'varchar'); //or any other type
Basically you can change any attribute from customers, categories & products like this;
$entityType = 'customer';//or catalog_category or catalog_product
$attributeCode = 'attribute_code_here';
$changeWhat = 'field_name_here';
$changeInto = 'new value here';
$this->updateAttribute($entityType, $attributeCode, $changeWhat, $changeInto);
To remove an attribute run this:
$this->removeAttribute('customer', 'attribute_code_here');
It follows the same rules as above.

Joomla - Custom Field doesn't show-up on Edit/Update

I've followed this Tutorial to add a custom field to the article content type and I was successful to make a new one with adding the following code:
In File : root/administrator/components/com_content/models/forms/article.xml
Code :
<field name="newText" type="editor" class="inputbox"
label="COM_CONTENT_FIELD_ARTICLETEXT_LABEL"
description="COM_CONTENT_FIELD_ARTICLETEXT_DESC"
filter="ContentHelper::filterText" buttons="true" />
In File : root/administrator/components/com_content/views/article/tmpl/edit.php
Code :
//Our new textbox
<div class="clr"></div>
<label>Article Text - New Text</label>
<div class="clr"></div>
<?php echo $this->form->getInput('newText'); ?>
and altered Database to add a new column for that new field.
ALTER TABLE 'j_content' ADD 'newText' VARCHAR( 255 ) NOT NULL;
On Article posting the data is successfully getting stored in Database.
The new custom field is visible when I'm posting a brand new article. But when I'm editing/updating the same new post, that newly added field is missing.
Is there a way to get this field even when we are editing the post/article.
Please, never overwrite core files or change the core database! This is not a good tutorial because it is not update-safe.
If you need additional fields for your content items, use a special core extension for this instead.
I recommend this one:
http://fieldsattach.com/. This method is update-safe.

Resources