Thứ Tư, 18 tháng 10, 2017
Chủ Nhật, 11 tháng 10, 2015
Cách nối file PDF thành 1 file duy nhất.
https://foxyutils.com/mergepdf/
hoặc : https://www.pdfmerge.com/
hoặc phần mềm ghép:
http://taimienphi.vn/download-adolix-split-merge-pdf-3860/taive
Truy cập vào link website này và chọn 2 file pdf và MERGE thành 1 file duy nhất
hoặc : https://www.pdfmerge.com/
hoặc phần mềm ghép:
http://taimienphi.vn/download-adolix-split-merge-pdf-3860/taive
Thứ Tư, 4 tháng 3, 2015
NHẬN THIẾT KẾ và XÂY DỰNG WEBSITE
NHẬN THIẾT KẾ và XÂY DỰNG WEBSITE.
WEBSITE (GIỚI THIỆU, TIN TỨC, BÁN HÀNG.......)
LIÊN HỆ:
+ Email:hongdiepbach@gmail.com
+ Skype: hoadiepdo99
Thứ Năm, 8 tháng 1, 2015
Thêm tùy chọn số trang trong magento
Adding rows per page to Magento admin grid
<select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
<option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
<option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
<option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
<option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
<option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
</select>
To this: <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
<option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
<option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
<option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
<option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
<option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
<option value="500"<?php if($this->getCollection()->getPageSize()==500): ?> selected="selected"<?php endif; ?>>500</option>
<option value="1000"<?php if($this->getCollection()->getPageSize()==1000): ?> selected="selected"<?php endif; ?>>1000</option>
</select>
Thứ Ba, 21 tháng 10, 2014
Thêm text phần vào invoice pdf trong magento
Adding a title to Invoice PDF in Magento
Muốn thêm text vào phần header hay footer trong file pdf cua invoice theo hình dưới:Tạo module tên pdf
app/code/local/Pdf/Sales/Model/Order/Pdf/Abstract.php
<?php
abstract class Pdf_Sales_Model_Order_Pdf_Abstract extends Mage_Sales_Model_Order_Pdf_Abstract
{
public function insertTitle(Zend_Pdf_Page $page, $text)
{
$this->_setFontBold($page, 17);
$docHeader = $this->getDocHeaderCoordinates();
$page->drawText($text, 200, $docHeader[1]+13, 'UTF-8');
}
}
app/code/local/Pdf/Sales/Model/Order/Pdf/Invoice.php
<?php
class Pdf_Sales_Model_Order_Pdf_Invoice extends Pdf_Sales_Model_Order_Pdf_Abstract
{
/**
* Draw header for item table
*
* @param Zend_Pdf_Page $page
* @return void
*/
protected function _drawHeader(Zend_Pdf_Page $page)
{
/* Add table head */
$this->_setFontRegular($page, 11);
$page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
$page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
$page->setLineWidth(0.5);
$page->drawRectangle(25, $this->y, 570, $this->y -15);
$this->y -= 10;
$page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
//columns headers
$lines[0][] = array(
'text' => Mage::helper('sales')->__('Products'),
'feed' => 35
);
$lines[0][] = array(
'text' => Mage::helper('sales')->__('SKU'),
'feed' => 290,
'align' => 'right'
);
$lines[0][] = array(
'text' => Mage::helper('sales')->__('Qty'),
'feed' => 435,
'align' => 'right'
);
$lines[0][] = array(
'text' => Mage::helper('sales')->__('Price'),
'feed' => 360,
'align' => 'right'
);
$lines[0][] = array(
'text' => Mage::helper('sales')->__('Tax'),
'feed' => 495,
'align' => 'right'
);
$lines[0][] = array(
'text' => Mage::helper('sales')->__('Subtotal'),
'feed' => 565,
'align' => 'right'
);
$lineBlock = array(
'lines' => $lines,
'height' => 5
);
$this->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
$this->y -= 20;
}
/**
* Return PDF document
*
* @param array $invoices
* @return Zend_Pdf
*/
public function getPdf($invoices = array())
{
$this->_beforeGetPdf();
$this->_initRenderer('invoice');
$pdf = new Zend_Pdf();
$this->_setPdf($pdf);
$style = new Zend_Pdf_Style();
$this->_setFontBold($style, 10);
foreach ($invoices as $invoice) {
if ($invoice->getStoreId()) {
Mage::app()->getLocale()->emulate($invoice->getStoreId());
Mage::app()->setCurrentStore($invoice->getStoreId());
}
$page = $this->newPage();
$order = $invoice->getOrder();
/* Add image */
$this->insertLogo($page, $invoice->getStore());
/* Add address */
$this->insertAddress($page, $invoice->getStore());
$page->setFillColor(new Zend_Pdf_Color_Html('#ffffff'));
$page->setLineColor(new Zend_Pdf_Color_Html('#ffffff'));
$page->setLineWidth(0.5);
$page->drawRectangle(25, $this->y, 570, $this->y-145);
$this->y -= 35;
/* Add head */
$this->insertOrder(
$page,
$order,
Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId())
);
/* Add Title */
$this->insertTitle($page,Mage::helper('sales')->__('INVOICE TO BUY'));
/* Add document text and number */
$this->insertDocumentNumber(
$page,
Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId()
);
/* Add table */
$this->_drawHeader($page);
/* Add body */
foreach ($invoice->getAllItems() as $item){
if ($item->getOrderItem()->getParentItem()) {
continue;
}
/* Draw item */
$this->_drawItem($item, $page, $order);
$page = end($pdf->pages);
}
/* Add totals */
$this->insertTotals($page, $invoice);
if ($invoice->getStoreId()) {
Mage::app()->getLocale()->revert();
}
}
$this->_afterGetPdf();
return $pdf;
}
/**
* Create new page and assign to PDF object
*
* @param array $settings
* @return Zend_Pdf_Page
*/
public function newPage(array $settings = array())
{
/* Add new table head */
$page = $this->_getPdf()->newPage(Zend_Pdf_Page::SIZE_A4);
$this->_getPdf()->pages[] = $page;
$this->y = 800;
if (!empty($settings['table_header'])) {
$this->_drawHeader($page);
// $this->_setFontRegular($page);
// $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
// $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
// $page->setLineWidth(0.5);
// $page->drawRectangle(25, $this->y, 570, $this->y-15);
// $this->y -=10;
// $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
// $page->drawText(Mage::helper('sales')->__('Product'), 35, $this->y, 'UTF-8');
// $page->drawText(Mage::helper('sales')->__('SKU'), 255, $this->y, 'UTF-8');
// $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
// $page->drawText(Mage::helper('sales')->__('QTY'), 430, $this->y, 'UTF-8');
// $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
// $page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
//
// $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
// $this->y -=20;
}
//This is the textline for the footer next page
$this->_setFontBold($page, $size = 8);
$page->drawText(Mage::helper('sales')->__('Thank you buy at sieuthithucpham.com') , 80, 30, 'UTF-8');
return $page;
}
}
app/code/local/Pdf/Sales/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Pdf_Sales>
<version>1.0</version>
</Pdf_Sales>
</modules>
<!-- following tells magento to override core models-->
<global>
<models>
<sales>
<rewrite>
<order_pdf_abstract>Pdf_Sales_Model_Order_Pdf_Abstract</order_pdf_abstract>
<order_pdf_invoice>Pdf_Sales_Model_Order_Pdf_Invoice</order_pdf_invoice> <order_pdf_creditmemo>Pdf_Sales_Model_Order_Pdf_Creditmemo</order_pdf_creditmemo>
</rewrite>
</sales>
</models>
</global>
</config>
app/etc/modules/Pdf_Sales.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Pdf_Sales>
<active>true</active>
<codePool>local</codePool>
</Pdf_Sales>
</modules>
</config>
Thứ Năm, 16 tháng 10, 2014
Lỗi không print được hóa đơn trong magento
Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with Zend_Pdf_FileParserDataSource::__construct() in /var/www/vhosts/website/httpdocs/includes/src/Zend_Pdf_FileParserDataSource_File.php on line 41
Tìm :
function lib/Zend/Pdf/FileParserDataSource.php.
change
abstract public function __construct();
toabstract public function __construct($filePath);
Sửa lỗi You don't have permission to access /phpmyadmin/ on this server Wamp
Solution:
goto C:\wamp\alias\ and edit the phpmyadmin.conf file using notepad
goto C:\wamp\alias\ and edit the phpmyadmin.conf file using notepad
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin2.11.6/"
# to give access to phpmyadmin from outside
# replace the lines
#
# Order Deny,Allow
# Deny from all
# Allow from 127.0.0.1
#
# by
#
# Order Allow,Deny
# Allow from all
#
<Directory "c:/wamp/apps/phpmyadmin2.11.6/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Allow from 127.0.0.1
</Directory>
Thay toàn bộ code trên vào file của bạn. Chú ý nhớ sữa đường dẫn thư mục phpmyadmin đúng với thư mục mà bạn cài đặt nhé.
Thứ Sáu, 15 tháng 8, 2014
Bỏ dấu cộng trong options products trong mangento
Mở file
$_priceInclTax = $this->getPrice($value['pricing_value'], true)+$this->getProduct()->getFinalPrice();
$_priceExclTax = $this->getPrice($value['pricing_value'])+$this->getProduct()->getFinalPrice();
app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php
Tìm 2 dòng priceInclTax đóng nó lại
và thay bằng 2 dòng dưới.
//$_priceInclTax =
$this->getPrice($value['pricing_value'], true);
//$_priceExclTax =
$this->getPrice($value['pricing_value']);
Thay bằng
$_priceInclTax = $this->getPrice($value['pricing_value'], true)+$this->getProduct()->getFinalPrice();
$_priceExclTax = $this->getPrice($value['pricing_value'])+$this->getProduct()->getFinalPrice();
Muốn bỏ dấu + có trong option tìm $sign='+';
đóng nó hoặc thay = dấu khác
Thứ Năm, 14 tháng 8, 2014
Thay đổi tiền tệ viêt nam trong magento
root/lib/Zend/Locale/Data/vi.xml
Tìm:
1.Trong <symbols>
<symbols>
<symbols>
<decimal>.</decimal>
<group>.</group>
<list>;</list>
………….</symbols>
<!—từ dấu , sửa thành dấu .à định vị tiền 1,000 đ thành 1.000 đ
2.Bạn tìm function roundPrice() trong app/code/core/Mage/Core/Model/Store.php public function roundPrice($price)
{
return round($price, 2);
}
public function roundPrice($price,$roundTo=3)
{
return round($price, $roundTo);
}
3.Tim /lib/zend/Currency.php protected $_options = array(
'position' => self::STANDARD,
'script' => null,
'format' => null,
'display' => self::NO_SYMBOL,
'precision' => 2,
'name' => null,
'currency' => null,
'symbol' => null
);
Thay bằng:
protected $_options =
array(
'position' => self::STANDARD,
'script' => null,
'format' => null,
'display' => self::NO_SYMBOL,
'precision' => 3,
'name' => null,
'currency' => null,
'symbol' => null
);
4.Mở file Currency.php trong
app\code\core\Mage\Directory\Mode
Tìm: public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
{
return
$this->formatPrecision($price, 2, $options,
$includeContainer, $addBrackets);
}
ð
Sửa lại thành số 3
public function format($price,
$options = array(), $includeContainer = true, $addBrackets = false)
{
return
$this->formatPrecision($price, 3, $options, $includeContainer, $addBrackets);
}
5.Sửa định vị tiền hiển thị danh sách sản phẩm trong
admin. Tìm
/js\varien\js.js: dòng 254:
var r = (j ? i.substr(0, j) + groupSymbol : "") + i.substr(j).replace(re, "$1" + groupSymbol) + (precision ? decimalSymbol + Math.abs(price - i).toFixed(precision).replace(/-/, 0).slice(2) : "")
Thêm +'0' vào cuối
dòng:
var r = (j ? i.substr(0, j) + groupSymbol :
"") + i.substr(j).replace(re, "$1" + groupSymbol) +
(precision ? decimalSymbol + Math.abs(price -
i).toFixed(precision).replace(/-/, 0).slice(2) : "")+'0'
vào trang admin
xóa cache và xem kết quả
Hiên thị tổng số tiền trong giỏ hàng
Để hiển thị tổng số tiền hiện tại trong giỏ hàng echo đoạn code dưới
<?php echo
$price=number_format(Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(),3);?>
khi hiển thị số tiền hàng đơn vị có dấu , (phẩy) ví dụ:
1,123.000 đ =>1.1.23.000 đ mới đúng
thay đổi thành
<?php echo $price = number_format(Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(), 3, ".", ".");
<?php echo $price = number_format(Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(), 3, ".", ".");
=>”.”,”.” là dấu chấm của hàng đơn vị
. Định dạng hiển thị thời gian đặt hàng theo dd/mm/yyyy HH:mm
. Định dạng hiển thị
thời gian đặt hàng theo dd/mm/yyyy HH:mm
Để
hiển thị thời gian đặt hàng theo mẫu ví dụ: 17/10/2014 13:05
Dùng
funtion formatDate();
Trong
file history.phtml là danh sách đơn đặt hàng tim chổ ngày đã đặt
<?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?>
<?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?>
Ta
thay thành:
<?php echo
$this->formatDate($_order->getCreatedAtStoreDate(),'short',true) ?>
Thứ Ba, 8 tháng 7, 2014
Xóa block trong 1 trang (How to remove block into a page of magento)
Xóa block trong 1 trang
(How to remove block into a page of magento/Adding A CSS Class To The Body tag)
ví dụ Trong trang cutomer muốn không hiển thị my cart / giỏ hàng thì làm như sau:
Mở file customer.xml layout
bỏ đoạn code dưới vào
<remove name="cart_sidebar"/>
nếu muốn dùng chung cho tất cả các trang thuộc customer thì bỏ vào trong thẻ
<default>
<remove name="cart_sidebar"/>
</default>
.....
(How to remove block into a page of magento/Adding A CSS Class To The Body tag)
ví dụ Trong trang cutomer muốn không hiển thị my cart / giỏ hàng thì làm như sau:
Mở file customer.xml layout
bỏ đoạn code dưới vào
<remove name="cart_sidebar"/>
nếu muốn dùng chung cho tất cả các trang thuộc customer thì bỏ vào trong thẻ
<default>
<remove name="cart_sidebar"/>
</default>
.....
Thêm tên class vào body trong magento (How to add class into body in magento)
Thêm tên class vào <body> trong magento (How to add class into body in magento)
Muốn thêm tên class vào body của 1 trang nào đó ví dụ trang customer.
mở file layout : customer.xml
chèn vào đoạn code :
<reference name="root">
<action method="addBodyClass"><classname>customers-profile</classname></action>
</reference>
trong đó customers-profile: là tên class mới thêm vào <body>
Muốn thêm tên class vào body của 1 trang nào đó ví dụ trang customer.
mở file layout : customer.xml
chèn vào đoạn code :
<reference name="root">
<action method="addBodyClass"><classname>customers-profile</classname></action>
</reference>
trong đó customers-profile: là tên class mới thêm vào <body>
Thứ Hai, 30 tháng 12, 2013
Phân trang trong wordpress
Phân trang
Dùng hàm paginate_links() có sẵn trong wordpress
<ul>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 1,
'category_name' => 'cong-nghe',
'paged' => $paged,
);
$the_query = new WP_Query($args);
while ($the_query->have_posts()):$the_query->the_post();
echo ' <li>';
echo ' <div class="title"> ';
the_title();
echo '</div>';
echo ' <div class="img">';
the_post_thumbnail();
echo '</div>';
echo ' <div class="content">';
echo get_the_content();
echo '</div>';
echo '</li>';
endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $the_query->max_num_pages));
?>
</ul>
Chủ Nhật, 29 tháng 12, 2013
Hiển thị bài viết ngẫu nhiên trong wordpress
Hiển thị bài viết ngẫu nhiên trong wordpress dùng thuộc thính 'orderby' => 'rand'
// hiển thị 5 bài viết ngẫu nhiên
<?php
global $post;
$args = array('numberposts' => 5, 'category_name' => 'thiet-bi-ho-tro', 'orderby' => 'rand');
$posts = get_posts($args);
foreach ($posts as $post): setup_postdata($post);?>
// Echo nội dung
.......................
<?php endforeach ?>
// hiển thị 5 bài viết ngẫu nhiên
<?php
global $post;
$args = array('numberposts' => 5, 'category_name' => 'thiet-bi-ho-tro', 'orderby' => 'rand');
$posts = get_posts($args);
foreach ($posts as $post): setup_postdata($post);?>
// Echo nội dung
.......................
<?php endforeach ?>
Hiển thị nội dung của các trang và bài viết
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile;?>
<?php the_content(); ?>
<?php endwhile;?>
Loại bỏ các thẻ html có trong chuỗi dữ liệu
dùng hàm strip_tags để bỏ đi các thẻ html có trong chuỗi khi hiển thị lên web
strip_tags($chuỗi);
strip_tags($chuỗi);
Hiển thị bài viết trong category theo tên Slug
Trong category của phần post bài viết tạo Slug có tên Tiện ích và Slug => tien-ich
Để gọi tất cả bài viết trong Slug ra:
<?php
global $post;
$args = array('numberposts' => 10, 'category_name' => 'loi-ich'); //số lượng hiển thị 10 sp
$posts = get_posts($args);
foreach ($posts as $post): setup_postdata($post);?>
//Echo nội dung ra ở đây
<?php echo the_post_thumbnail(); ?>
<php echo the_title(); ?>
<?php echo the_content(); ?>
<?php endforeach ?>
Để gọi tất cả bài viết trong Slug ra:
<?php
global $post;
$args = array('numberposts' => 10, 'category_name' => 'loi-ich'); //số lượng hiển thị 10 sp
$posts = get_posts($args);
foreach ($posts as $post): setup_postdata($post);?>
//Echo nội dung ra ở đây
<?php echo the_post_thumbnail(); ?>
<php echo the_title(); ?>
<?php echo the_content(); ?>
<?php endforeach ?>
Hiển thị dữ liệu category child của page by id
Ví dụ: trong page giới thiệu ta có id nó là 12, và subcategory của page gồm có các trang con
Để hiển thị các trang con có trong trang Giới thiệu đoạn code sau:
$mypages = get_pages(array('post_type' => 'page', 'number' => '6', 'child_of' => '12', 'sort_column' => 'post_date', 'sort_order' => 'desc'));
foreach ($mypages as $pages) {
$content = $pages->post_content;//lấy nội dung
?>
// HIỂN THỊ NỘI DUNG RA
<div class="title-pro-home">
<?php echo $pages->post_title; ?> //lấy post title
<?PHP echo $content ;?>
</div>
<div class="img-pro-home"><?php echo get_the_post_thumbnail($pages->ID, 'medium'); ?> //lấy thumbnail
</div>
<?php } ?>
Để hiển thị các trang con có trong trang Giới thiệu đoạn code sau:
$mypages = get_pages(array('post_type' => 'page', 'number' => '6', 'child_of' => '12', 'sort_column' => 'post_date', 'sort_order' => 'desc'));
foreach ($mypages as $pages) {
$content = $pages->post_content;//lấy nội dung
?>
// HIỂN THỊ NỘI DUNG RA
<div class="title-pro-home">
<?php echo $pages->post_title; ?> //lấy post title
<?PHP echo $content ;?>
</div>
<div class="img-pro-home"><?php echo get_the_post_thumbnail($pages->ID, 'medium'); ?> //lấy thumbnail
</div>
<?php } ?>
Đăng ký:
Nhận xét (Atom)

