How do i remove the Period column from my custom report?
i tried with
unset($this->_columns['period']);
but its not working.
I need to start my columns like order number, order date,subtotal etc etc.
This is loaded by a custom grid of Backend of Magento, you need identify this. To find the custom block you can active backend hints and see what grid are loaded in this section.
You can active backend hints with the next Sql:
UPDATE core_config_data SET scope_id = 0 WHERE path like 'dev/debug/template_hints%';
Execute always in development enviroment. Never in production site
You can see how to active backend hints in this link, http://www.damianculotta.com.ar/2009/07/11/mostrar-phtmls-y-bloques-usados-en-el-skin-de-backend-de-magento/ sorry, this is in spanish, I don´t find this information in english :(
With this you also to know the type of block load in this grid, this is the important date. Next you need create a little module that rewrite this block.
Whit this method you can see that the next dates
Template
adminhtml\default\default\template\widget/grid.phtml
Block
Mage_Adminhtml_Block_Report_Sales_Sales_Grid
in the block you can see the next columm in the construct
$this->addColumn('period', array(
'header' => Mage::helper('sales')->__('Period'),
'index' => 'period',
'width' => 100,
'sortable' => false,
'period_type' => $this->getPeriodType(),
'renderer' => 'adminhtml/report_sales_grid_column_renderer_date',
'totals_label' => Mage::helper('sales')->__('Total'),
'html_decorators' => array('nobr'),
));
You need remove this columm in you custom block, always in separate extension.
If you don´t know how you can rewrite a block, only need said me :P
Hope help you
Related
I'm working on a custom module and I would like to definiate a custom node type with some fields like image field. I don't like to use features it is great module but I don't like to use it. My question is that where I can find some information about for example the image field spexial settings?
'job_post_image' => array(
'field_name' => 'job_post_image',
'label' => $t('Images related to this job post.'),
'type' => 'image',
'cardinality' => -1,
??? what are the more options? For example file path, alt tag and etc.
I don't understand why you wouldn't use the Features module for this. Your use case is exactly why that module exists. Even though you don't want to use the module in production, you might want to create your content type and export it as a feature to examine the code to see how it is all put together.
There is also a pretty comprehensive look at creating an image field programatically at https://www.drupal.org/node/1044248.
On an observer file I need to detect if the loaded page corresponds to a product. I've been using a similar method to the one used on the checked answer on this question:
if (!(Mage::registry('current_product'))) return;
But until now we were testing on development. From today we are testing on pre-production servers, with lot of modules and plugins. Until now it worked seamesly but now it does not work, it does not detect when a product page is loaded. I think is related with the url rewrite to show a more "friendly" url's but can not detect how to solve it. I took a look into Alan Storm tutorial In Depth Magento Dispatch but I still can get what is wrong or what do I need to change.
Any idea? Or some other solution on how to detect when a product page is loaded?
You've verified that the observer is being hit? Make sure that for the event you are triggering on has a unique name for that event. For example in the following code the name "catalog_product_set_price" must be unique in regards to "catalog_product_load_after" event. I'm assuming you're getting into the observer, but just in case. This risk becomes possible if you add a bunch of new modules to an instance.
<catalog_product_load_after>
<observers>
<catalog_product_set_price>
<type>singleton</type>
<class>NamespaceModule_Model_Observer</class>
<method>set_price2</method>
</catalog_product_set_price>
</observers>
</catalog_product_load_after>
You could use the following array to check where you are:
$currentPageArray = array(
'request_string'=> Mage::app()->getFrontController()->getRequest()->getRequestString(),
'uri' => Mage::app()->getFrontController()->getRequest()->getRequestUri(),
'route' => Mage::app()->getFrontController()->getRequest()->getRouteName(),
'action' => Mage::app()->getFrontController()->getRequest()->getActionName(),
'controller' => Mage::app()->getFrontController()->getRequest()->getControllerName()
);
it will output something like:
Array
(
[request_string] => /some-category/some-product-page-url.html
[uri] => /catalog/product/view/id/64806/category/17
[route] => catalog
[action] => view
[controller] => product
)
You could try a different observer.
controller_action_layout_render_before_catalog_product_view
controller_action_postdispatch_catalog_product_view
I'm configuring a magento webshop for one of our clients. They've got colorcodes and due to that I have to set up configurable products. However, before the configurable products are being shown on the webshop I need to select an attribute to assign to it...
Now this is really unhandy if I have to import an entire catalog of +/- 800 products...
I already found the next script to make this automatically but I have no clue where to put it... I've already tried using it in the configurable.php file, didn't work. Please help me out!
foreach($configAttrCodes as $attrCode){
$super_attribute= Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product',$attrCode->code);
$configurableAtt = Mage::getModel('catalog/product_type_configurable_attribute')->setProductAttribute($super_attribute);
$newAttributes[] = array(
'id' => $configurableAtt->getId(),
'label' => $configurableAtt->getLabel(),
'position' => $super_attribute->getPosition(),
'values' => $configurableAtt->getPrices() ? $configProduct->getPrices() : array(),
'attribute_id' => $super_attribute->getId(),
'attribute_code' => $super_attribute->getAttributeCode(),
'frontend_label' => $super_attribute->getFrontend()->getLabel(),
);
echo "test ";
}
echo "test2 ";
if(empty($existingAtt) && !empty($newAttributes)){
$configProduct->setCanSaveConfigurableAttributes(true);
$configProduct->setConfigurableAttributesData($newAttributes);
$configProduct->save();
This script is best used a shell script to assign the config attributes to products. Its not complete thou. I had to add alot to this script, like the ability to feed it product ids, and attribute codes to configure along with the configurable attributes.
Its hard to show you whats missing from it, since you need alot more than just this script to assign the attributes. I run one script that grabs all the ids of the configurable products and then makes a cache file with them. I them use another script to feed those ids to the above script so that it may configure them. So in total, 3 scripts. I then use a shell script to run that process.
This was posted by another user to help point you in the direction you need to be heading, but is no way a standalone script. I can email you my source files for all three scripts and you can reverse them down to see what I did if that helps.
Okay, so I am uploading documents when a user registers on my site, I collect some personal information and save it. Now I have had a bit of a problem, I split up the main registration form into a couple of view, where the user once logged in can now edit certain information, like for example one field called personal_introduction. For some reason this wont save, even though there are no validation errors on the field. Messed around in the model, to try pick up the problem and fount THIS causes the problem:
'document_file' => array(
'checkuploadedit' =>array(
'rule' => array('checkUpload', false),
'message' => 'Please select your document.',
),
'checkuploadedit' => array(
'rule' => array('extension', array('doc', 'docx', 'txt', 'rtf')),
'message' => 'File extentions allowed: .doc .docx .txt .rtf - we do NOT accept pdf format.'
)
),
Once I remove this from my model, it saves the data. Now its weird for me that the main registration form gives no problems, and that this view that does not even contain a form input called "document_file" fails the save.
Any ideas...Please!!! Obviously I need to validate the upload.
I tried this: validation on a input file in cakephp , thinking that maybe the above code is not correct, still no luck.
Thanks in advance for your answers.
Cheers Louis.
I went on to further investigate the problem, and found the following, which I still cant explain. When submitting views that do not contain the upload form on the same model, it still tries to validate the upload form, I could actually see the value for one as if submitted, even though it was not. so the only solution I got was to go use unset($this->data['user']['document']) for the actions which do not have the document upload form field. Hope this makes sense.
i am using magento 1.6
and want to add cutomer email,coupon code and shipping detials to sales order grid
can you guys please tell me how to do that
it tried using this
copy
app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
to
app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php
then under the following line
$collection = Mage::getResourceModel($this->_getCollectionClass());
add
$collection->getSelect()->joinLeft(array('sfo'=>'sales_flat_order'),'sfo.entity_id=main_table.entity_id',array('sfo.customer_email'));
then in the _prepareColumns() method add
$this->addColumn('customer_email', array(
'header' => Mage::helper('sales')->__('Customer Email'),
'index' => 'customer_email',
'filter_index' => 'sfo.customer_email',
));
note. you will need to add a 'filter_index' to all calls to addColumn pointing to main_table.field_name
but its not working
I believe that I have found an extension to do exactly what you are seeking. There is also this free extension but I do not know if it's strong enough to do what you need. Worst case, it is a starting point for you?? And I'm fairly sure this extension does everything you want... I'm tempted to buy it!
As I often say, better to buy an extension, so you won't write code.