In Magento, How does one modify the admin store select list at the search filter stage and not the select stage? - magento

Magento Admin has a store select drop down list of all the stores.
I have added an addititional "SELECT ALL STORES" value to allow me to know when a user wishes to carry out a task on all stores.
I based this customisation on enterprise magento version 1.9 although I think the version is quite irrelevant since my question is quite generic to magento I think.
How do I stop my "SELECT ALL STORES" from being selected by default in the search ?
/index.php/admin/admin/urlrewrite/index

The store list select form is built here:
app\code\core\Adminhtml\Block\Widget\Grid\Column\Filter\Store.php
Once I found that, I could override it to the local code pool and make the modifications I needed.
public function getHtml()
{
$storeModel = Mage::getSingleton('adminhtml/system_store');
/* #var $storeModel Mage_Adminhtml_Model_System_Store */
$websiteCollection = $storeModel->getWebsiteCollection();
$groupCollection = $storeModel->getGroupCollection();
$storeCollection = $storeModel->getStoreCollection();
$allShow = $this->getColumn()->getStoreAll();
$html = '<select name="' . $this->_getHtmlName() . '" ' . $this->getColumn()->getValidateClass() . '>';
$value = $this->getColumn()->getValue();
//if ($allShow) {
$html .= '<option value=""' . (**$value == 0** ? ' selected="selected"' : '') . '>' . Mage::helper('adminhtml')->__('All Store Views') . '</option>';
//} else {
// $html .= '<option value=""' . (!$value ? ' selected="selected"' : '') . '></option>';
//}

Related

Paypal Notify URL returned nothing using CodeIgniter

First of all I had my sandbox merchant account configured to receive IPN. I will show you the first half of my codes that is sent to Paypal:
function process() {
$my_email = 'jaylimix-facilitator#hotmail.com';
$item_name = $this->input->post('item_name');
$amount = $this->input->post('amount');
$function = $this->input->post('function');
$return_url = base_url() . 'order/'.$function;
$cancel_url = 'http://cancel.com';
$notify_url = base_url() . 'test';
$querystring .= "?business=" . urlencode($my_email) . "&";
$querystring .= "item_name=" . urlencode($item_name) . "&";
$querystring .= "amount=" . urlencode($amount) . "&";
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$querystring .= "$key=$value&";
}
$querystring .= "return=" . urlencode($return_url) . "&";
$querystring .= "cancel_return=" . urlencode($cancel_url) . "&";
$querystring .= "notify_url=" . urlencode($notify_url);
header('location:https://www.sandbox.paypal.com/cgi-bin/webscr' . $querystring);
}
The customer is redirected to PayPal to complete payment. When the Pay button is clicked, I checked to see if any POST variable is received:
class Test extends CI_Controller{
function index(){
foreach ($_POST as $key => $value) {
echo $key . ' ' . $value . '<br/>';
}
}
}
But there is none received and I do not know where the problem is. Please give your advices, thanks!
When the Pay button is clicked, I checked to see if any POST variable is received:
It isn't. PayPal invokes the notifyURL separately at a later time, not 'when the Pay button is clicked'. When PayPal returns to your site, all you know is that they have been to PayPal. In any case you shouldn't do anything of value for the customer until PayPal tells you that you actually have the money.

Joomla archive by year?

I posted this question before, but it got drowned and barely got any views so I figured I'd try one more time.
This seems like such a strange thing to not exist yet but I've been looking for ages. Is there an archive plug-in or component, or any way really, to simply sort the archive by year? All I want is to display columns for each year, with the year displayed above each column, containing a (clickable) list of archived titles. I'm using Joomla 2.5.
Anyone know how to do this? Whether it's through a plug-in/component or editing the existing archive code; don't care how, just want to get it done. Any help would be much appreciated.
You could try these extensions:
JExtBOX Article History - 5$
Demo : http://demo.jextbox.com/
Monthly Archive
Demo: http://www.joomla357.com/demo/monthly-archive.html - ?$
Mod LCA
Demo: http://www.jonijnm.es/web/mod-lca.html - free
This might not be an ideal solution and not too clean either, but I used Monthly Archive and changed the getMonths() method in the monthlyarchiveclass to include this:
$byYear = array();
foreach($month_years_unique as $month_year){
$year = explode('-',$month_year);
$byYear[$year[1]] = array();
}
foreach($results_months as $result){
$year = $result['year'];
$id = $result['id'];
$byYear[$year] = array(
$id => $result,
);
}
if(count($byYear) != 0){
foreach($byYear as $year => $value){
$html .= '<div class="archivecolumn"><h1>'.$year.'</h1>';
$html .= '<ul class="itemlist">';
foreach($value as $item){
$cat = $this->getCatName($item['catid']);
$link = 'index.php/' . $cat . '/' . $item['id'] . '-' . $item['alias'];
$html .= '<li>';
$html .= ''.$item['title'].'';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '</div>';
}
} else {
$html .= 'No archived works.';
}

build category tree for categories and sub categories

i am trying to built category tree for the categories and sub categories in custom admin module, if possible to override the default category tree present in edit tab of product.
Below is the code which i am working, it is able to build category tree but it lack the checkbox ability. any sugestion would be appreciated
<?php
$rootcatId= Mage::app()->getStore()->getRootCategoryId();
$categories = Mage::getModel('catalog/category')->getCategories($rootcatId);
function get_categories($categories) {
$array= '<ul>';
foreach($categories as $category) {
$cat = Mage::getModel('catalog/category')->load($category->getId());
$count = $cat->getProductCount();
$array .= '<li>'.
'<a href="' . Mage::getUrl($cat->getUrlPath()). '">' .
$category->getName() . "(".$count.")</a>\n";
if($category->hasChildren()) {
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
$array .= get_categories($children);
}
$array .= '</li>';
}
return $array . '</ul>';
}
echo get_categories($categories); ?>
Please clarify your question as it's bad idea to override core functionality because same function is used by different modules instead you can check functionality of these
app/design/adminhtml/default/default/template/catalog/product/edit/categories.ph‌​tml app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php
and then reflect these to your template files

Errors, warning, notices with a cross to hide them using Jquery. How to extend the core message class in a right way to achieve this?

I want my error, warning, notification messages on frontend to extend a bit. So,
I need to override
Mage_Core_Block_Messages
class's
public function getGroupedHtml()
{
$types = array(
Mage_Core_Model_Message::ERROR,
Mage_Core_Model_Message::WARNING,
Mage_Core_Model_Message::NOTICE,
Mage_Core_Model_Message::SUCCESS
);
$html = '';
foreach ($types as $type) {
if ( $messages = $this->getMessages($type) ) {
if ( !$html ) {
$html .= '<' . $this->_messagesFirstLevelTagName . ' class="messages">';
}
$html .= '<' . $this->_messagesSecondLevelTagName . ' class="' . $type . '-msg">';
$html .= '<' . $this->_messagesFirstLevelTagName . '>';
foreach ( $messages as $message ) {
$html.= '<' . $this->_messagesSecondLevelTagName . '>';
$html.= '<' . $this->_messagesContentWrapperTagName . '>';
$html.= ($this->_escapeMessageFlag) ? $this->htmlEscape($message->getText()) : $message->getText();
$html.= '</' . $this->_messagesContentWrapperTagName . '>';
$html.= '</' . $this->_messagesSecondLevelTagName . '>';
}
$html .= '</' . $this->_messagesFirstLevelTagName . '>';
$html .= '</' . $this->_messagesSecondLevelTagName . '>';
}
}
if ( $html) {
$html .= '</' . $this->_messagesFirstLevelTagName . '>';
}
return $html;
}
to extend the html and put a cross in the message box and implement Jquery. logic: on click close hide error box. So customers can upon click hide the box.
I believe this class doesn't have any template file and the html it is rendering from the this block class itself as I can see in getGroupedHtml() method.
So, I am going to override this method and add more html.
Also, I want to do this only for one theme and not in Admin
What is the better way to achieve this?
Please suggest me something. Thanks
You could accomplish this without overriding anything and by just going for JavaScript (jQuery) only.
Here is a simple script that should do the job.
var messages = jQuery("ul.messages li[class$='-msg']");
messages.each(function(){
var message = jQuery(this);
message.find('span').append('<span class="close">X</span>');
});
messages.on('click', function(){
var message = jQuery(this).closest("li[class$='-msg']");
message.hide();
});
The script adds a 'X' to the end of every message and removes (hides) the message when it's clicked.
The only thing left to do is to give the cross (span X) some styling.
You could place this in your footer template for the correct theme.

Print All Users - Joomla 2.5

I am new to Joomla. I have created website using Joomla 2.5. I have login page which is default Joomla user management system.
What I want is display all user data in a tabular format. How could I do the same?
Edit 1
I can see the users with below steps.
Go to administrator page as www.site.com/administrator.
Login as admin
Click Users >> User Manager menu and then I can see the list of users.
I want to print same list, however on the website and not on administrator site at backend.
you can do this run the query on your page where you want to show user list. you can fetch all users table field with $row object.
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__users" ;
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo $row->id.'|'.$row->username.'|'.$row->email;
}
Edit 1
Below is what I used.
Installed extension Flexi Custom Code.
Create module using this, add above code in it and appear that menu on the menu where you want to display.
You'll need some sort of component for this. This user profile component for example (N.B. Using this as my example as a work colleague once used it - not as customizable as I would have liked - but probably OK for what your after. I'm sure there are more as there's an entire member list category.)
Just install one of them and choose what you want to show. Add it to a menu like any other component and off you go!
Two possible solutions
Use the User Profile Component available in JED
Enable "User - Contact Creator" plugin to create a Contact profile for each new user and then use the Joomla built-in Menu Item to list all contacts
// my example with opt-groups, preselected user and better user-ids
function getUserList ($user_id) {
$db = JFactory::getDBO ();
$db->setQuery ("SELECT id, username, usertype FROM ' . $db->quoteName ('#__users') . ' ORDER BY usertype,username ASC");
$rows = $db->loadAssocList ();
static $opt_tag;
$list = '<option value="0">' . JText::_ ('SELECTION') . '</option>';
foreach ($rows as $row) {
if (empty ($opt_tag) || $opt_tag != $row['usertype']) {
$list .= '<optgroup label="' . $row['usertype'] . '">';
$opt_tag = $row['usertype'];
}
if ($row['id'] < 10) {
$id = '000' . $row['id'];
}
elseif ($row['id'] < 100) {
$id = '00' . $row['id'];
}
elseif ($row['id'] < 1000) {
$id = '0' . $row['id'];
}
$list .= '<option value="' . $row['id'] . '"' . (((int) $user_id == $row['id']) ? ' selected="SELECTED"' : '') . '>' . $id . ' - ' . $row['username'] . '</option>';
if (empty ($opt_tag) || $opt_tag != $row['usertype']) {
$list .= '</optgroup>';
}
}
return $list;
}

Resources