X hide

Magento Estimated Delivery Date v1.x Developer's Guide & API Reference

From Plumrocket Documentation

You are viewing:  Magento-estimated-delivery-date-wiki-32.png  Estimated Delivery Date

Estimated Delivery Date Manual Configuration

Estimated Delivery Date module will automatically add "Delivery Dates" on Product Page if enabled in back-end. However, you can change standard "Delivery Date" display or position in the front-end. To do this follow the instructions below.

Product Page

To have the Delivery Date displayed on the page, make sure you have the corresponding block in the layout template file:

app/design/frontend/default/default/layout/catalog.xml
<block type="estimateddelivery/product" name="estimateddelivery_product" as="estimateddelivery" template="estimateddelivery/product.phtml" />

Now, edit HTML template and place following code in desired place on Product Page:

app/design/frontend/default/default/template/catalog/product/view.phtml
<?php echo $this->getChildHtml('estimateddelivery') ?>

The changes in the code above are enough to display "Estimated Delivery Date" on Product Page. However you can also change design of Estimated Delivery block. To do this, edit corresponding file:

theme_path/default/template/estimateddelivery/product.phtml
Category Page

In order to add the Estimated Delivery to the category page, you will have to edit the file:

app/design/frontend/<your active theme>/default/template/catalog/category/view.phtml

and enter the following code where the desired block should be located.

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



Display Estimated Delivery Dates and Shipping Dates in Magento for Specific Categories & Products

The following methods in "Plumrocket_Estimateddelivery_Block_Product" block allow to show shipping and delivery dates for specific products:

setProduct($product)

Allows to set the product for which the dates will be shown.

Example :

Let's show the date for "related" products on Product Page:

  1. $relatedProducts = get_related_products(); // where get_related_products() is some custom method to retrieve related products
  2. $estimatedBlock = $this->getLayout()->createBlock('estimateddelivery/product')->setTemplate('estimateddelivery/product.phtml');
  3. foreach ($relatedProducts as $_product) {
  4.  echo $estimatedBlock->setProduct($_product)->toHtml();
  5. }
Example:

On Product Page with custom design we can display dates for "related" products and immediately after that display dates for the current product:

  1. <div class="related_dates">
  2. <?php
  3. $relatedProducts = get_related_products(); // where get_related_products() is some custom method to retrieve related products
  4. foreach ($relatedProducts as $_product) {
  5.  echo $this->getChild('estimateddelivery')->setProduct($_product)->toHtml();
  6. }
  7. ?>
  8. </div>
  9. <div class="main_date">
  10. <?php $this->getChild('estimateddelivery')->reset()->toHtml(); ?>
  11. </div>
setCategory($category)

Allows to set the category for which the dates will be shown.

Example :

Let's display html block that contains delivery date for the set category:

  1. $customCategory = Mage::getModel('catalog/category')->load(<any id>);
  2. echo $this->getLayout()
  3.  ->createBlock('estimateddelivery/product')
  4.  ->setTemplate('estimateddelivery/category.phtml')
  5.  ->setCategory($customCategory)
  6.  ->toHtml();
getProduct()

Allows to get the product for which the dates will be shown. Note: If no product was indicated manually - current product will be returned on Product Page.

getCategory()

Allows to get the category for which the dates will be shown. Note: If no category was indicated manually - current category will be returned on Product Page or Category Page.

reset()

Allows to clear all current settings. After calling this method, the other methods (getProduct and getCategory) will return current product (on Product Page) and current category (on Product Page or Category Page) accordingly. This method comes handy for displaying dates of custom products (categories) on the product (category) page, and for returning to default settings.

Example code of layout.xml file:

Let's display block with date for the product by inserting it into the layout:

  1. <catalog_product_default>
  2.  <reference name="content">
  3.  <block type="estimateddelivery/product" name="estimateddelivery_product" as="estimateddelivery" template="estimateddelivery/product.phtml" />
  4.  </reference>
  5. </catalog_product_default>

Fixing issue with estimated delivery attribute import

Magento has a problem with importing product attribute values that have custom source model.

1. In order to import the attributes correctly using Magento import, you need to perform some changes in the code.
Please, follow the instructions below.

Find the file:

app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php


and copy it into the file:

app/code/local/Mage/ImportExport/Model/Import/Entity/Product.php


Open created file and change the following code:

 protected $_indexValueAttributes = array(
 'status',
 'tax_class_id',
 'visibility',
 'gift_message_available',
 'custom_design'
 );

to this code:

 protected $_indexValueAttributes = array(
 !!-'estimated_delivery_enable',
 'estimated_shipping_enable',-!!
 'status',
 'tax_class_id',
 'visibility',
 'gift_message_available',
 'custom_design'
 );

Save your changes


2. If you are using Magmi for import, you need to change the code in this software, as it has the same issue as Magento.

Please, follow the instructions below to change the code.

Find and edit file:

/magmi/plugins/inc/magmi_defaultattributehandler.php


After the following code in method handleIntAttribute :

// if it's tax_class, get tax class id from item value
case "tax/class_source_product":
$ovalue = $this->getTaxClassId($ivalue);
break;


add next code lines:

!!-// if it's estimated delivery class
case "estimateddelivery/attribute_source_enabley":
$ovalue = $ivalue;
break;-!!


It should look like this:

// if it's tax_class, get tax class id from item value
case "tax/class_source_product":
$ovalue = $this->getTaxClassId($ivalue);
break;
!!-// if it's estimated delivery class
case "estimateddelivery/attribute_source_enabley":
$ovalue = $ivalue;
break;-!!

Estimated Delivery Date Extension for Magento Estimated Delivery Date Extension for Magento

Buy Magento Estimated Delivery Date Extension on Plumrocket Store
Click below to check key features of this extension, view live demo and screenshots:

Navigation