How to show newsletter subscription date on grid? - php

I want to show newsletter subscription date on Newsletter Subscribers Grid.
I am using magento 1.8.1.
How it will be possible.
Please suggest?
Thanks

By default, There isn't a subscription date stored when the customer subscribes, you will have to:
Add a subscription_date column to the newsletter_subscriber table
Override Mage_Newsletter_Model_Subscriber and in subscribe function, add code to set the subscription date to the model before saving $this->setSubscriptionDate(yourDateGoesHere)
Then, in order to show it int the backend, you will have to override Mage_Adminhtml_Block_Newsletter_Subscriber_Grid and add this code in _prepareColumns function, just place it in the place you want it to show.
$this->addColumn('subscription_date', array(
'header' => Mage::helper('newsletter')->__('Date'),
'index' => 'subscription_date',
'type' => 'datetime',
'align' => 'center',
'gmtoffset' => true
));

Related

Prestashop 1.6.0.9 multishop, filter admin products by status

Faced some trouble within prestashop 1.6.0.9 admin products filtering by status in multishop enabled.
To explain in details picture below
As seen in picture product filtered by status "NO", but it displays on. Does anynone has such issue, by looking at controller and database, status is filtered by product table - where product is off, but displays from product_shop table where that shop active field is on. How can i manage filtering by status, am i facing with this alone? is there a fix already to this (HelperList?).
Can i somehow to set that list would be filtered by joint tables?
$this->table = 'product';
$this->fields_list['active'] = array(
'title' => $this->l('Status'),
'active' => 'status',
'filter_key' => $alias.'!active',
'align' => 'text-center',
'type' => 'bool',
'class' => 'fixed-width-sm',
'orderby' => false
);
maybe you can use ['list'] => $this->countries_array as option in your field list see documentation here http://doc.prestashop.com/display/PS16/Using+the+HelperList+class

how to add country column in prestashop AdminCustomersControllerCore

i want to add an extra column in AdminCustomersControllerCore so that it will show a new column in my back office manage customer page.
Use the hook actionControllerNameListingFieldsModifier to add fields.
Every admin controller calls this hook before generating the list/table.
Hook::exec('action'.$this->controller_name.'ListingFieldsModifier', array(
'select' => &$this->_select,
'join' => &$this->_join,
'where' => &$this->_where,
'group_by' => &$this->_group,
'order_by' => &$this->_orderBy,
'order_way' => &$this->_orderWay,
'fields' => &$this->fields_list,
));
You will need to modify select and fields variable to include your own. You might need to modify join variable as well if you have data in a custom table.

How do i add status column in product grid section in manage category in magento?

How can i add status column in product grid in manage categories section? I want to add status column next to SKU.
Catalog / Manage Categories / select any category and you can able to see the mapped products under "category products". There i want to add status column.
Thanks in advance.
You can copy this file app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php to your local folder or directly in app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php
Line 79, just before ->addAttributeToSelect('price'),
add this code: ->addAttributeToSelect('status')
Line 128, just before $this->addColumn('price', array(, add this code:
$this->addColumn('status',
array(
'header'=> Mage::helper('catalog')->__('Status'),
'width' => '70px',
'index' => 'status',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
));
Run Compilation again if it is enabled. Refresh your page, you'll see "Status" column next to the SKU column

Opencart adding a new field to the customer view of the admin section

I have added a new field to my database. I also have managed to add necessary codes and functions in catalog section. This new field is related to the customer. The data related to this new field gets added successfully to the database.
This new field belongs to Customer table.
Now, I want to know, when viewing customer's details in the admin section, how this new field should be retrieved from database? I mean which file should be edited for this purpose?
getCustomer($customer_id) and getCustomers($data = array()) are the functions used to get customer data.
Since they are SELECT * querys your field is being processed automatically.
Afterwards you need to go in the Controller section in the controller\sale folder and there you have customer.php, custom_field.php and and edit the ones that you need. For example:
$this->data['customers'][] = array(
'customer_id' => $result['customer_id'],
'name' => $result['name'],
'email' => $result['email'],
'customer_group' => $result['customer_group'],
'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
'approved' => ($result['approved'] ? $this->language->get('text_yes') : $this->language->get('text_no')),
'ip' => $result['ip'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'selected' => isset($this->request->post['selected']) && in_array($result['customer_id'], $this->request->post['selected']),
'action' => $action
);
add your field in this array (this is from customer.php).
And finally edit the .tpl files that are called from the view\template\sale folder so they appear where they want them to.
Hope i was clear enough.

Magento coupon discount

I am setting up magento store which buy stuff from customers. Instead of decreasing Price of the product, I want to increase the price of the product using coupon code. in which file i need to make changes for this.
Update 1:
Thanks Amit.
I have another question. I like to change "Discount" to "Promotion" in cart and onepage checkout. However, I can't find any file location. I have turn on the Template Path Hints from Configuration. Can anyone help me out ?
If you need only fixed amount discount, then you can remove the validate for Discount Amount field so that you can add negative value in this field, so when you try to apply this coupon it will automatically add that amount instead to decrease. So you need to override below two classes.
For more details on Magento override see this Link.
Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_Actions
find this code
$fieldset->addField('discount_amount', 'text', array(
'name' => 'discount_amount',
'required' => true,
'class' => 'validate-not-negative-number',
'label' => Mage::helper('salesrule')->__('Discount Amount'),
));
and change it to
$fieldset->addField('discount_amount', 'text', array(
'name' => 'discount_amount',
'required' => true,
'label' => Mage::helper('salesrule')->__('Discount Amount'),
));
and remove the below code
if ($this->hasDiscountAmount()) {
if ((int)$this->getDiscountAmount() < 0) {
Mage::throwException(Mage::helper('rule')->__('Invalid discount amount.'));
}
}
from
Mage_Rule_Model_Abstract::_beforeSave()
Have a look at the CartController.php in Mage/Checkout/Controllers and at the Mage_Sales_Model_Quote model with its methode -collectTotals().
You need to create a new module where you override the model or create an observer.

Categories