#StackBounty: #magento-1.9 #filter #order-grid Filter on order comment history in order grid magento 1

Bounty: 50

I have added an column to the magento 1 order grid. it renders the order history of the order.
I have made a renderer with the following code:

class Mage_Adminhtml_Block_Sales_Order_Renderer_Red extends 

Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    public function render(Varien_Object $row)
    {
        $orderId = $row->getId();
        $order = Mage::getModel('sales/order')->load($orderId);
        $history = $order->getStatusHistoryCollection()->getFirstItem();
        return $history->getComment();
    }
}

And added it to the add column:

'history' => array(
'header' => Mage::helper('sales')->__('History status'),
'type'  => 'text',
'renderer' => new Mage_Adminhtml_Block_Sales_Order_Renderer_Red,
),

My question is:
How can i filter on the text that is displayed in the order grid?

Thanks.


Get this bounty!!!

#StackBounty: #magento-1.9 #php #jquery #session #cookie How to add "httponly" attribute set on existing cookie ? (Magento 1)

Bounty: 50

In Magento 1

I can see many of the cookie are without Secure flag and HttpOnly set on website.

Is their any way to set Secure flag and HttpOnly set on all server Cookie ?

I need to make all server cookie secure.

I have tried “Use HTTP Only” option in Magento to add "httponly" flag in cookies.

System > Configuration > General > Web > Session Cookie Management

It works but not for all cookies.

Any thoughts on this ?

Thankyou


Get this bounty!!!

#StackBounty: #magento-1.9 #product #exception #zipcode I want to set exceptions on add_to_cart button

Bounty: 50

I am building E-Commerce website in Magento 1.9. I want to add below functionalities on my add_to_cart button on product page:

  1. Want to keep add_to_cart button disabled always.
  2. I want every user check the zipcode first & if their zipcode is valid then only unfreeze the add_to_cart button, if the zipcode is invalid then keep the add_to_cart button disabled.
  3. Always refresh the product page whenever user checks zipcode & keep add_to_cart button disabled if zipcode is invalid & unfreeze if it is valid.

These exceptions are useful for me because I am running my E-Commerce store in limited area. I have attached the view.phtml, restriczip.phml & product page screenshot. If any more things needed please ask me. Any help will be appreciated.

view.phtml

<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<script type="text/javascript">
    var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
<div class="product-view">
    <div class="product-essential">
        <form action="<?php echo $this->getSubmitUrlCustom($_product, array('_secure' => $this->_isSecure()), false) ?>"
              method="post"
              id="product_addtocart_form"
              <?php if ($_product->getOptions()): ?> enctype="multipart/form-data" <?php endif; ?>>
            <?php echo $this->getBlockHtml('formkey') ?>
            <div class="no-display">
                <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
                <input type="hidden" name="related_product" id="related-products-field" value="" />
            </div>

            <div class="product-img-box">
                <div class="product-name">
                    <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
                </div>
                <?php echo $this->getChildHtml('media') ?>
            </div>

            <div class="product-shop">
                <div class="product-name">
                    <span class="h1"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></span>
                </div>

                <div class="price-info">
                    <?php echo $this->getPriceHtml($_product); ?>
                    <?php echo $this->getChildHtml('bundle_prices') ?>
                    <?php echo $this->getTierPriceHtml() ?>
                </div>

                <div class="extra-info">
                    <?php echo $this->getReviewsSummaryHtml($_product, 'default', false)?>
                    <?php echo $this->getChildHtml('product_type_availability'); ?>
                </div>

                <?php echo $this->getChildHtml('alert_urls') ?>

                <?php if ($_product->getShortDescription()):?>
                    <div class="short-description">
                        <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
                    </div>
                <?php endif;?>




                <?php echo $this->getChildHtml('other');?>

                <?php if ($_product->isSaleable() && $this->hasOptions()):?>
                    <?php echo $this->getChildChildHtml('container1', '', true, true) ?>
                <?php endif;?>

            </div>

            <div class="add-to-cart-wrapper">
                <?php echo $this->getChildHtml('product_type_data') ?>
                <?php echo $this->getChildHtml('extrahint') ?>

                <?php if (!$this->hasOptions()):?>
                    <div class="add-to-box">
                        <?php if($_product->isSaleable()): ?>
                            <?php echo $this->getChildHtml('addtocart') ?>
                            <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
                                <span class="or"><?php echo $this->__('OR') ?></span>
                            <?php endif; ?>
                        <?php endif; ?>
                        <?php echo $this->getChildHtml('addto') ?>
                        <?php echo $this->getChildHtml('sharing') ?>
                    </div>
                    <?php echo $this->getChildHtml('extra_buttons') ?>
                <?php elseif (!$_product->isSaleable()): ?>
                    <div class="add-to-box">
                        <?php echo $this->getChildHtml('addto') ?>
                        <?php echo $this->getChildHtml('sharing') ?>
                    </div>
                <?php endif; ?>
            </div>

            <?php echo $this->getChildHtml('related_products') ?>

            <div class="clearer"></div>
            <?php if ($_product->isSaleable() && $this->hasOptions()):?>
                <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
            <?php endif;?>
        </form>
        <script type="text/javascript">
        //<![CDATA[
            var productAddToCartForm = new VarienForm('product_addtocart_form');
            productAddToCartForm.submit = function(button, url) {
                if (this.validator.validate()) {
                    var form = this.form;
                    var oldUrl = form.action;

                    if (url) {
                       form.action = url;
                    }
                    var e = null;
                    try {
                        this.form.submit();
                    } catch (e) {
                    }
                    this.form.action = oldUrl;
                    if (e) {
                        throw e;
                    }

                    if (button && button != 'undefined') {
                        button.disabled = true;
                    }
                }
            }.bind(productAddToCartForm);

            productAddToCartForm.submitLight = function(button, url){
                if(this.validator) {
                    var nv = Validation.methods;
                    delete Validation.methods['required-entry'];
                    delete Validation.methods['validate-one-required'];
                    delete Validation.methods['validate-one-required-by-name'];
                    // Remove custom datetime validators
                    for (var methodName in Validation.methods) {
                        if (methodName.match(/^validate-datetime-.*/i)) {
                            delete Validation.methods[methodName];
                        }
                    }

                    if (this.validator.validate()) {
                        if (url) {
                            this.form.action = url;
                        }
                        this.form.submit();
                    }
                    Object.extend(Validation.methods, nv);
                }
            }.bind(productAddToCartForm);
        //]]>
        </script>
    </div>

    <div class="product-collateral toggle-content tabs">
        <?php if ($detailedInfoGroup = $this->getChildGroup('detailed_info', 'getChildHtml')):?>
            <dl id="collateral-tabs" class="collateral-tabs">
                <?php foreach ($detailedInfoGroup as $alias => $html):?>
                    <dt class="tab"><span><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></span></dt>
                    <dd class="tab-container">
                        <div class="tab-content"><?php echo $html ?></div>
                    </dd>
                <?php endforeach;?>
            </dl>
        <?php endif; ?>
    </div>

    <?php echo $this->getChildHtml('upsell_products') ?>
    <?php echo $this->getChildHtml('product_additional_data') ?>

</div>

restrictzip.phtml

<div id="meetanshi-restrictzip">
    <ul class="messages cod-available">
        <li class="success-msg">
            <ul>
                <li>
                    <span>
                    <?php echo $this->__(Mage::helper('restrictzip')->getSuccessMsg()) ?> 
                    </span>
                </li>
            </ul>
        </li>
    </ul>
    <ul class="messages cod-available">
        <li class="success-msg"   style="display:<?php echo Mage::helper('restrictzip')->isShowDelivery();?>">
            <ul>
                <li><span id="extpected_delivery_time"> </span>
                </li>
            </ul>
        </li>
    </ul>
    <ul class="messages cod-not-available">
        <li class="error-msg">
            <ul>
                <li><span>
                        <?php echo $this->__(Mage::helper('restrictzip')->getErrorMsg()) ?>
                    </span>
                </li>
            </ul>
        </li>
    </ul>
    <ul class="messages cod-validation">
        <li class="error-msg">
            <ul>
                <li><span><?php echo $this->__('Please enter a ZIP code.')?></span></li>
            </ul>
        </li>
    </ul>
    <ul class="messages cod-error">
        <li class="error-msg">
            <ul>
                <li>
                    <span>
                        <?php echo $this->__('There was a problem while checking for COD availability. 
                        Please try again after some time.')?>
                    </span>
                </li>
            </ul>
        </li>
    </ul>
    <h4>
        <?php echo $this->__(Mage::helper('restrictzip')->getTitle())?>
    </h4>
    <label for="meetanshi-zip"><?php echo $this->__('ZIP Code')?></label>
    <input id="meetanshi-zip" type="text" name="zip_code" value="" maxlength="10" class="input-text"/>

    <button class="button check-zip" type="button" class="button"><span><span><?php echo $this->__('Check')?></span></span></button>

    <img src="<?php echo $this->getSkinUrl('meetanshi/loading.gif'); ?>" width="20" height="20"
         alt="" class="loading-spinner"/>
</div>
<script type="text/javascript">
    var meetanshi_restrictzip_ajax_url = '<?php echo $this->getUrl('restrictzip/restrictzip'); ?>';
</script>

<style>
#meetanshi-restrictzip {
    padding: 15px;
    border: 1px solid #CCC;
    margin-bottom: 15px;
}
#meetanshi-restrictzip .input-text {
  height: 38px;
  width: 100px;
}
.button.check-zip {
  height: 38px;
}
#meetanshi-restrictzip .cod-available,
#meetanshi-restrictzip .cod-not-available,
#meetanshi-restrictzip .cod-validation,
#meetanshi-restrictzip .cod-error,
#meetanshi-restrictzip .loading-spinner {
    display: none;
}
</style>


<script>
document.observe( 'dom:loaded', function() {

    $$( '#meetanshi-restrictzip .check-zip' ).invoke( 'observe', 'click', function( e ) {
        var the_zip_code = $( 'meetanshi-zip' ).value;
        if ( the_zip_code == '' ) {
            $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
            $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
            $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'block' }); } );
            $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'none' }); } );

            return;
        }

        $$( '#meetanshi-restrictzip .loading-spinner' ).each( function (e) { e.setStyle({ display: 'inline-block' }); } );
        $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
        $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
        $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
        $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'none' }); } );

        // Send an AJAX request
        new Ajax.Request( meetanshi_restrictzip_ajax_url, {
            method: 'post',
            parameters: { zip_code: the_zip_code },
            asynchronous: true,
            onSuccess: function( response ) {
                var json_response = response.responseText.evalJSON();
                
                
                if ( json_response.status == 'success' ) {
                    if ( json_response.allowed_zip == true ) {
                        $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'block' }); } );
                        
                        $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        
                        document.getElementById("extpected_delivery_time").innerHTML = "Estimated Delivery Time : "+json_response.estimate_delivery_time;                       
                    }
                    else {
                        $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'block' }); } );
                        $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                        $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                    }
                }
                else {
                    $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                    $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                    $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                    $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'block' }); } );
                }

                $$( '#meetanshi-restrictzip .loading-spinner' ).each( function (e) { e.setStyle({ display: 'none' }); } );
            },
            onException: function( request, ex ) {
                //alert( ex.toSource() );
            },
            onFailure: function() {
                $$( '#meetanshi-restrictzip .cod-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                $$( '#meetanshi-restrictzip .cod-not-available' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                $$( '#meetanshi-restrictzip .cod-validation' ).each( function (e) { e.setStyle({ display: 'none' }); } );
                $$( '#meetanshi-restrictzip .cod-error' ).each( function (e) { e.setStyle({ display: 'block' }); } );

                $$( '#meetanshi-restrictzip .loading-spinner' ).each( function (e) { e.setStyle({ display: 'none' }); } );
            }
        });


        e.stop();
    });

});

</script>

enter image description here


Get this bounty!!!

#StackBounty: #magento-1.9 #api #collection #soap-api-v2 Get shipments by order number in Magento 1.9 API

Bounty: 100

I am trying to get the list of shipments for a given order via the API (I use the SOAP API but I don’t think it matters).

I don’t have the order ID but the 9-digit number (the increment_id from the sales_flat_order table).

I can see the following code in the API method I am trying to call:

    /**
     * Retrieve shipments by filters
     *
     * @param null|object|array $filters
     * @return array
     */
    public function items($filters = null)
    {
        $shipments = array();

        $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
            ->addAttributeToSelect('increment_id')
            ->addAttributeToSelect('created_at')
            ->addAttributeToSelect('total_qty')
            ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
            ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
            ->joinAttribute('order_increment_id', 'order/increment_id', 'order_id', null, 'left')
            ->joinAttribute('order_created_at', 'order/created_at', 'order_id', null, 'left');

        $apiHelper = Mage::helper('api');
        $filters = $apiHelper->parseFilters($filters, $this->_attributesMap['shipment']);
        foreach ($filters as $field => $value) {
            $shipmentCollection->addFieldToFilter($field, $value);
        }

        ...
        return $shipments;
    }

From: Mage/Sales/Model/Order/Shipment/Api.php (slightly edited for brevity).

I don’t fully understand the syntax of this query but it seems like a join is made with the orders table, and then filters are added from the filters API parameter.

I have tried to call this API this way (calling from a C# program):

var shipments = Client.SalesOrderShipmentList(sessionId, new Filters
{
    filter = new AssociativeEntity[]
    {
        new AssociativeEntity
        {
            key = "order_increment_id",
            value = "000000006"
        }
    }
});

I am getting the following error:

‘SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘order_increment_id’ in ‘where clause’, query was: SELECT main_table.increment_id, main_table.created_at, main_table.total_qty FROM sales_flat_shipment AS main_table WHERE (order_increment_id = ‘000000006’)’

It seems that the join isn’t being translated to SQL.
I have tried several things like prefixing the column name with the orders table name, to no avail.

Am I doing something wrong?

Thank you


Get this bounty!!!

#StackBounty: #magento-1.9 #cms-block #widget #widgets #widget-instance Magento 1.9.4.0 CMS Block Widget Issue

Bounty: 50

I’m trying to add widget to cms block or page but when i add it only display short code on page and not render, i tried different magento default widgets results is same

enter image description here

also tried using code on phtml template

echo $this->getLayout()->createBlock('cms/block')->setBlockId('home-top-cms')->toHtml()

But it also gives same results.

also checked by adding block type to system permission but still no luck, anyone know how fix this issue please


Get this bounty!!!

#StackBounty: #magento-1.9 #category #category-products #category-tree #category-listing SQL code to get the Product details with categ…

Bounty: 50

enter image description hereI’m using Magento 1.9, We have a requirement to show the product details with category tree heirarchy. Have searched this in google and haven’t find any answers.

I have to create a report(using a BI tool) ,So i need to find a way to do this in pure SQL.

Does anyone have any suggestions on how to achieve this?

Below is the expected sample of expected output.There are 3 levels of categories and main category.
So i want the Products which is the lowest level to be under the corresponding categories in a tree structure.


Get this bounty!!!

#StackBounty: #magento-1.9 #catalog-price-rules Apply catalogue price rule based on cart subtotal

Bounty: 50

I want to apply different catalog price rules, based on the subtotal of the current quote.

I have set up multiple catalog price rules.

Rule 1
Priority 3
Discount amount: 10%
Stop Further Rules Processing: Yes

Rule 2
Priority 2
Discount amount: 15%
Stop Further Rules Processing: Yes

Rule 3
Priority 1
Discount amount: 20%
Stop Further Rules Processing: Yes

Rule 4
Priority 0
Discount amount: 25%
Stop Further Rules Processing: Yes

I want to check the cart total before I decide which catalog rule to use.

Example: If the cart subtotal is between 1000 and 10000, apply rule 3.

I think this should be possible because Magento stores all the product prices in the database and is not calculated “on the run”.

Where does Magento check the priority of a catalog price rule? My assumption would be, that I can implement my own custom logic somewhere around there.

I know this is possible using shopping cart price rules, but I need this to work using catalog price rules, as I want to display the product price before its added to the cart.


Get this bounty!!!

#StackBounty: #magento-1.9 #catalog-price-rules Apply catalog price rule based on cart subtotal

Bounty: 50

I want to apply different catalog price rules, based on the sub total of the current quote.

I have setup multiple catalog price rule.

Rule 1
Priority 3
Discount amount: 10%
Stop Further Rules Processing: Yes

Rule 2
Priority 2
Discount amount: 15%
Stop Further Rules Processing: Yes

Rule 3
Priority 1
Discount amount: 20%
Stop Further Rules Processing: Yes

Rule 4
Priority 0
Discount amount: 25%
Stop Further Rules Processing: Yes

I want to check cart total, before i decide which catalog rule to use.

Example: If the cart subtotal is between 1000 and 10000, apply rule 3.

I think this should be possible, because Magento stores all the product prices in the database and is not calculated “on the run”.

Where does Magento check the priority of a catalog price rule? My assumption would be, that i can implement my own custom logic somewhere around there.

I know this is possible using shoppingcart price rules, but i need this to work using catalog pricerules, as i want to display the product price, before its added to the cart.


Get this bounty!!!