جستجو
محصولات
    منو بسته
    2 دی 1403

    اسکریپتی برای حذف تمام محصولات از دیتابیس به همراه وابستگی هایش

    8 سال پیش
    #314
    من تعداد زیادی در فروشگه تعریف کرده ام و الان می خواهم همه محصولات ، دسته بندی ها و ویژگی های محصول و همه موارد دیگر که در رابطه با محصول است  را به یکباره حذف کنم . آیا اسکریپتی برای حذف از دیتابیس وجود دارد ؟

    هنگام حذف محصولات از طریق بخش مدیریت ، محصولات فقط مخفی می شوند و عملا از دیتابیس حذف نمی شودند. می خواهم از دیتابیس حذف شوند.
    نقل قول
    0
    8 سال پیش
    #101
    اسکریپ تست شده در ناپ کامرس نسخه 3.70 برای حذف همه محصولات ناپ کامرس:


    DELETE FROM ShoppingCartItem
    DELETE FROM OrderNote
    DELETE FROM RecurringPayment
    DELETE FROM RewardPointsHistory
    DELETE FROM [Order]
    DELETE FROM PredefinedProductAttributeValue
    DELETE FROM RelatedProduct
    DELETE FROM ProductAttribute
    DELETE FROM Picture
    DELETE FROM Product_Category_Mapping
    DELETE FROM Product
    DELETE FROM PredefinedProductAttributeValue
    DELETE FROM Product_Picture_Mapping
    DELETE FROM Product_ProductAttribute_Mapping
    DELETE FROM PredefinedProductAttributeValue
    DELETE FROM Product_ProductTag_Mapping
    DELETE FROM Product_SpecificationAttribute_Mapping
    DELETE FROM ProductReview
    DELETE FROM ProductReviewHelpfulness
    Delete UrlRecord Where EntityName = 'Product'

    DBCC CHECKIDENT (ShoppingCartItem, RESEED, 0)
    DBCC CHECKIDENT (OrderNote, RESEED, 0)
    DBCC CHECKIDENT (RecurringPayment, RESEED, 0)
    DBCC CHECKIDENT (RewardPointsHistory, RESEED, 0)
    DBCC CHECKIDENT ([Order], RESEED, 0)
    DBCC CHECKIDENT (RelatedProduct, RESEED, 0)
    DBCC CHECKIDENT (ProductAttribute, RESEED, 0)
    DBCC CHECKIDENT (Picture, RESEED, 0)
    DBCC CHECKIDENT (Product_Category_Mapping, RESEED, 0)
    DBCC CHECKIDENT (Product, RESEED, 0)
    DBCC CHECKIDENT (PredefinedProductAttributeValue, RESEED, 0)
    DBCC CHECKIDENT (Product_Picture_Mapping, RESEED, 0)
    DBCC CHECKIDENT (Product_ProductAttribute_Mapping, RESEED, 0)
    DBCC CHECKIDENT (Product_SpecificationAttribute_Mapping, RESEED, 0)
    DBCC CHECKIDENT (PredefinedProductAttributeValue, RESEED, 0)
    DBCC CHECKIDENT (ProductReview, RESEED, 0)
    DBCC CHECKIDENT (ProductReviewHelpfulness, RESEED,0)



    برای حذف دسته بندی ها به همراه تمام زیر دسته ها:


    DELETE FROM Category;
    DBCC CHECKIDENT (Category, RESEED, 0)



    برچسب ها: حذف کل محصولات ناپ کامرس ، حذف سمپل دیتای ناپ کامرس ، حذف Sample Data ناپ کامرس
    نقل قول
    0
    8 سال پیش
    #105
    عالی بود ممنون .
    طراحی قالب اختصاصی برای ناپ کامرس
    نقل قول
    0
    8 سال پیش
    #171
    اسکریپ تست شده در ناپ کامرس نسخه 3.80 برای حذف محصولات:


    DELETE FROM ShoppingCartItem
    DELETE FROM OrderNote
    DELETE FROM RecurringPayment
    DELETE FROM RewardPointsHistory
    DELETE FROM GiftCard
    DELETE FROM [Order]
    DELETE FROM PredefinedProductAttributeValue
    DELETE FROM RelatedProduct
    DELETE FROM ProductAttribute
    DELETE FROM Picture
    DELETE FROM Product_Category_Mapping
    DELETE FROM Product
    DELETE FROM PredefinedProductAttributeValue
    DELETE FROM Product_Picture_Mapping
    DELETE FROM Product_ProductAttribute_Mapping
    DELETE FROM PredefinedProductAttributeValue
    DELETE FROM Product_ProductTag_Mapping
    DELETE FROM Product_SpecificationAttribute_Mapping
    DELETE FROM ProductReview
    DELETE FROM ProductReviewHelpfulness
    DELETE FROM Forums_PrivateMessage
    Delete UrlRecord Where EntityName = 'Product'

    DBCC CHECKIDENT (ShoppingCartItem, RESEED, 0)
    DBCC CHECKIDENT (OrderNote, RESEED, 0)
    DBCC CHECKIDENT (RecurringPayment, RESEED, 0)
    DBCC CHECKIDENT (RewardPointsHistory, RESEED, 0)
    DBCC CHECKIDENT ([Order], RESEED, 0)
    DBCC CHECKIDENT (RelatedProduct, RESEED, 0)
    DBCC CHECKIDENT (ProductAttribute, RESEED, 0)
    DBCC CHECKIDENT (Picture, RESEED, 0)
    DBCC CHECKIDENT (Product_Category_Mapping, RESEED, 0)
    DBCC CHECKIDENT (Product, RESEED, 0)
    DBCC CHECKIDENT (PredefinedProductAttributeValue, RESEED, 0)
    DBCC CHECKIDENT (Product_Picture_Mapping, RESEED, 0)
    DBCC CHECKIDENT (Product_ProductAttribute_Mapping, RESEED, 0)
    DBCC CHECKIDENT (Product_SpecificationAttribute_Mapping, RESEED, 0)
    DBCC CHECKIDENT (PredefinedProductAttributeValue, RESEED, 0)
    DBCC CHECKIDENT (ProductReview, RESEED, 0)
    DBCC CHECKIDENT (ProductReviewHelpfulness, RESEED,0)
    نقل قول
    0
    8 سال پیش
    #172
    روش دیگر استفاده از یک Stored Procedure  با دو پارامتر  بولین (0 یا 1) است که علاوه بر حذف کل محصولات ، امکان حذف دسته بندی ها و تولید کنندگان را نیز دارد.
    اسکریپت زیر در نسخه 3.80 تست شده است:


    CREATE PROCEDURE [dbo].[RESET_DB]
    (
       @ResetCategories bit,
       @ResetManufacturers bit
    )
    AS
    SET NOCOUNT ON;
    ----------------------------------------------------------------------------------------
    -- Delete Product and Order and related tables and data.
    DELETE FROM ShoppingCartItem;
    DELETE FROM OrderNote;
    DELETE FROM RecurringPayment;
    DELETE FROM RewardPointsHistory;
    DELETE FROM [Order];  -- many deletes cascade from here
    DELETE FROM ProductAttributeCombination;
    DELETE FROM RelatedProduct;
    DELETE FROM ProductAttributeValue;
    DELETE FROM ProductAttribute;
    DELETE FROM Picture;
    DELETE FROM Product_Category_Mapping;
    DELETE FROM Product;
    DELETE FROM Product_Picture_Mapping;
    DELETE FROM Product_ProductAttribute_Mapping;
    DELETE FROM Product_ProductTag_Mapping;
    DELETE FROM Product_SpecificationAttribute_Mapping;
    DELETE FROM ProductReview;
    DELETE FROM ProductReviewHelpfulness;
    DELETE UrlRecord Where EntityName = 'Product';
     
    -- Delete Category and related tables and data.
    IF (@ResetCategories = 1) BEGIN
       DELETE FROM Category;
       DELETE UrlRecord Where EntityName = 'Category';
    END
     
    -- Delete Manufacturer and related tables and data.
    IF (@ResetManufacturers = 1) BEGIN
       DELETE FROM Manufacturer;
       DELETE UrlRecord Where EntityName = 'Manufacturer';
    END
     
    -- Reseed IDENTITY property
    DBCC CHECKIDENT (ShoppingCartItem, RESEED, 0);
    DBCC CHECKIDENT (OrderNote, RESEED, 0);
    DBCC CHECKIDENT (RecurringPayment, RESEED, 0);
    DBCC CHECKIDENT (RewardPointsHistory, RESEED, 0);
    DBCC CHECKIDENT ([Order], RESEED, 0);
    DBCC CHECKIDENT(ProductAttributeCombination, RESEED, 0);
    DBCC CHECKIDENT (RelatedProduct, RESEED, 0)
    DBCC CHECKIDENT ([ProductAttributeValue], RESEED, 0);
    DBCC CHECKIDENT (ProductAttribute, RESEED, 0);
    DBCC CHECKIDENT (Picture, RESEED, 0);
    DBCC CHECKIDENT (Product_Category_Mapping, RESEED, 0);
    DBCC CHECKIDENT (Product, RESEED, 0);
    DBCC CHECKIDENT (Product_Picture_Mapping, RESEED, 0);
    DBCC CHECKIDENT (Product_ProductAttribute_Mapping, RESEED, 0);
    DBCC CHECKIDENT (Product_SpecificationAttribute_Mapping, RESEED, 0);
    DBCC CHECKIDENT (ProductReview, RESEED, 0);
    DBCC CHECKIDENT (ProductReviewHelpfulness, RESEED, 0);
     
    IF (@ResetCategories = 1) BEGIN
       DBCC CHECKIDENT (Category, RESEED, 0);
    END
     
    IF (@ResetManufacturers = 1) BEGIN
       DBCC CHECKIDENT (Manufacturer, RESEED, 0);
    END
     
    -- Rebuild indexes on Product and Order and related tables.
    ALTER INDEX ALL ON dbo.ShoppingCartItem REBUILD;
    ALTER INDEX ALL ON dbo.OrderNote REBUILD;
    ALTER INDEX ALL ON dbo.RecurringPayment REBUILD;
    ALTER INDEX ALL ON dbo.RewardPointsHistory REBUILD;
    ALTER INDEX ALL ON dbo.[Order] REBUILD;
    ALTER INDEX ALL ON dbo.ProductAttributeCombination REBUILD;
    ALTER INDEX ALL ON dbo.RelatedProduct REBUILD;
    ALTER INDEX ALL ON dbo.ProductAttribute REBUILD;
    ALTER INDEX ALL ON dbo.Picture REBUILD;
    ALTER INDEX ALL ON dbo.Product_Category_Mapping REBUILD;
    ALTER INDEX ALL ON dbo.Product REBUILD;
    ALTER INDEX ALL ON dbo.Product_Picture_Mapping REBUILD;
    ALTER INDEX ALL ON dbo.Product_ProductAttribute_Mapping REBUILD;
    ALTER INDEX ALL ON dbo.Product_SpecificationAttribute_Mapping REBUILD;
    ALTER INDEX ALL ON dbo.ProductReview REBUILD;
    ALTER INDEX ALL ON dbo.ProductReviewHelpfulness REBUILD;
     
    IF (@ResetCategories = 1) BEGIN
       ALTER INDEX ALL ON dbo.Category REBUILD;
    END
     
    IF (@ResetManufacturers = 1) BEGIN
       ALTER INDEX ALL ON dbo.Manufacturer REBUILD;
    END
     
    -- Update statistics
    EXEC sp_updatestats;
     
    /*---- EOSP ----*/

    نقل قول
    0
    7 سال پیش
    #368
    سلام،مهندس
    عالی بود سپاسگزارم
    پارسا
    نقل قول
    0
    4 سال پیش
    #3193
    برای ناپ کامرس 4.20 از کوئری زیر استفاده کنید:
    DELETE FROM ActivityLog
    DELETE FROM Affiliate
    DELETE FROM BlogComment
    DELETE FROM BlogPost
    DELETE FROM Category
    DELETE FROM Customer_CustomerRole_Mapping  WHERE Customer_ID > 1
    DELETE FROM CustomerAddresses
    UPDATE Customer SET BillingAddress_Id = NULL, ShippingAddress_Id = NULL
    DELETE FROM Customer WHERE ID > 3
    DELETE FROM [Address]
    DELETE FROM CustomerPassword WHERE ID > 3
    DELETE FROM Download
    DELETE FROM Forums_Forum
    DELETE FROM GenericAttribute WHERE EntityId > 1
    DELETE FROM GiftCard
    DELETE FROM [Log]
    DELETE FROM Manufacturer
    DELETE FROM News
    DELETE FROM NewsComment
    DELETE FROM [Order]
    DELETE FROM OrderItem
    DELETE FROM OrderNote
    DELETE FROM Picture
    DELETE FROM PictureBinary
    DELETE FROM Poll
    DELETE FROM PollAnswer
    DELETE FROM PollVotingRecord
    DELETE FROM Product
    DELETE FROM Product_Category_Mapping
    DELETE FROM Product_Picture_Mapping
    DELETE FROM Product_ProductAttribute_Mapping
    DELETE FROM Product_ProductTag_Mapping
    DELETE FROM ProductAttribute
    DELETE FROM ProductAttributeCombination
    DELETE FROM ProductAttributeValue
    DELETE FROM ProductReview
    DELETE FROM ProductReviewHelpfulness
    DELETE FROM ProductTag
    DELETE FROM QueuedEmail
    DELETE FROM RecurringPaymentHistory
    DELETE FROM RelatedProduct
    DELETE FROM ReturnRequest
    DELETE FROM RewardPointsHistory
    DELETE FROM SearchTerm
    DELETE FROM ShoppingCartItem
    DELETE FROM SpecificationAttribute
    DELETE FROM SpecificationAttributeOption
    DELETE FROM StorePickupPoint
    DELETE FROM UrlRecord WHERE ID > 12
    DELETE FROM Vendor
    DELETE FROM Warehouse


    DBCC CHECKIDENT (ActivityLog, RESEED, 0)
    DBCC CHECKIDENT ([Address], RESEED, 0)
    DBCC CHECKIDENT (Affiliate, RESEED, 0)
    DBCC CHECKIDENT (BlogComment, RESEED, 0)
    DBCC CHECKIDENT (BlogPost, RESEED, 0)
    DBCC CHECKIDENT (Category, RESEED, 0)
    DBCC CHECKIDENT (Download, RESEED, 0)
    DBCC CHECKIDENT (Forums_Forum, RESEED, 0)
    DBCC CHECKIDENT (GiftCard, RESEED, 0)
    DBCC CHECKIDENT ([Log], RESEED, 0)
    DBCC CHECKIDENT (Manufacturer, RESEED, 0)
    DBCC CHECKIDENT (News, RESEED, 0)
    DBCC CHECKIDENT (NewsComment, RESEED, 0)
    DBCC CHECKIDENT ([Order], RESEED, 0)
    DBCC CHECKIDENT (OrderItem, RESEED, 0)
    DBCC CHECKIDENT (OrderNote, RESEED, 0)
    DBCC CHECKIDENT (Picture, RESEED, 0)
    DBCC CHECKIDENT (PictureBinary, RESEED, 0)
    DBCC CHECKIDENT (Poll, RESEED, 0)
    DBCC CHECKIDENT (PollAnswer, RESEED, 0)
    DBCC CHECKIDENT (PollVotingRecord, RESEED, 0)
    DBCC CHECKIDENT (Product, RESEED, 0)
    DBCC CHECKIDENT (Product_Category_Mapping, RESEED, 0)
    DBCC CHECKIDENT (Product_Picture_Mapping, RESEED, 0)
    DBCC CHECKIDENT (Product_ProductAttribute_Mapping, RESEED, 0)
    DBCC CHECKIDENT (ProductAttribute, RESEED, 0)
    DBCC CHECKIDENT (ProductAttributeCombination, RESEED, 0)
    DBCC CHECKIDENT (ProductAttributeValue, RESEED, 0)
    DBCC CHECKIDENT (ProductReview, RESEED, 0)
    DBCC CHECKIDENT (ProductReviewHelpfulness, RESEED, 0)
    DBCC CHECKIDENT (ProductTag, RESEED, 0)
    DBCC CHECKIDENT (QueuedEmail, RESEED, 0)
    DBCC CHECKIDENT (RecurringPaymentHistory, RESEED, 0)
    DBCC CHECKIDENT (RelatedProduct, RESEED, 0)
    DBCC CHECKIDENT (ReturnRequest, RESEED, 0)
    DBCC CHECKIDENT (RewardPointsHistory, RESEED, 0)
    DBCC CHECKIDENT (SearchTerm, RESEED, 0)
    DBCC CHECKIDENT (ShoppingCartItem, RESEED, 0)
    DBCC CHECKIDENT (SpecificationAttribute, RESEED, 0)
    DBCC CHECKIDENT (SpecificationAttributeOption, RESEED, 0)
    DBCC CHECKIDENT (StorePickupPoint, RESEED, 0)
    DBCC CHECKIDENT (Vendor, RESEED, 0)
    DBCC CHECKIDENT (Warehouse, RESEED, 0)
    نقل قول
    0
    09127857628